Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

attachment icon not being displayed

jackmaessenjackmaessen ✭✭✭
edited February 2014 in Vanilla 2.0 - 2.8

using 2.0.18.10 with Bootstrap theme

I noticed that when attaching a file (.zip), the attachment is not being displayed under the textarea. When posting the topic, it is being displayed. So the problem is not that it is not being uploaded but it is not visible under the textarea when you choose the file before posting (under the browse button actually). Only images are visible under the textarea when you attach them.
And there is a difference between the browsers: if choosen a .zip file, see images below
I use FileUploadDetect
What can be the problem because when i attach a .zip file on this forum, it is being displayed under the textarea

![](

it is a little bit misleading because the user can not see if the file is being attached or not, especially on FF

This problem appears on both plugins; FileUpload and FileUploadDetect; i have tested them both

After posting: it is displayed perfectly!

«1

Comments

  • Options
    jackmaessenjackmaessen ✭✭✭
    edited February 2014

    i looked into the console of FF on the place the icon(image) should appear, and it says: "Failed to load given url"

    This is the url i can see in the console:

    <img src="/index.php?p=/plugins/FileUpload/images/oxygen-style/application-zip.png">
    

    When i type the url in the browser, he gives me a 404
    But this is really the place where the .png file is

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited February 2014

    Have you tried using rewrite url ?

    try changing that in the htaccess file too. I noticed this in your forum in the past and mentioned it. This problem may well be due to that.

    <img src="/index.php?p=/plugins/FileUpload/images/oxygen-style/application-zip.png" alt="image">

    there should not be access to the file upload folder other than to get the image

    try this and tell me if it gets the image

    <img src="/plugins/FileUpload/images/oxygen-style/application-zip.png" alt="image">

    Try changing that in the web inspector and see if the image shows.

    Or go to the image in the file manager and click it to view the image and see what url it gives you.

    the link should be like this for the thumbnails

    <img src="/forum/uploads/thumbnails/FileUpload/31/dbafefb1215babeaed83b548501c6a.png" class="ImageThumbnail" alt="UserImage">

    and for the uploads

    <img src="/forum/uploads/FileUpload/31/dbafefb1215babeaed83b548501c6a.png class="Image" alt="UserImage">

    this is what it looks like using clean urls

  • Options

    i put these lines in my .htaccess file but it doesn't change anything; still in the console: "Failed to load given url"

    RewriteEngine On
    RewriteRule /plugins/FileUpload/images/oxygen-style/application-zip.png /index.php?p=/plugins/FileUpload/images/oxygen-style/application-zip.png [NC,L]
    
    
  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited February 2014

    no please follow here,

    if your forum is in the root this is what the htaccess need to look like

    # Modified
    # If you modify this file then change the above line to: # Modified
    <IfModule mod_rewrite.c>
       RewriteEngine On
       # Certain hosts may require the following line.
       # If vanilla is in a subfolder then you need to specify it after the /. 
       # (ex. You put Vanilla in /forum so change the next line to: RewriteBase /forum)
       RewriteBase /
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteRule ^(.*)$ index.php\?p=$1 [QSA,L]
    </IfModule>
    

    Then set this in your config.php

    $Configuration['Garden']['RewriteUrls']=TRUE;

    Depending on where your forum is installed you change / to /forum or whatever the name .
    example:

    RewriteBase /forum

    or

    RewriteBase /thisismyforumname

    or

    just

    /

  • Options
    jackmaessenjackmaessen ✭✭✭
    edited February 2014

    My forum is in the root, so i put these lines above into my .htaccess and i added the $configuration line into the config.php
    But still the same problem
    Edit:
    In the console it says still:

    <img src="/index.php?p=/plugins/FileUpload/images/oxygen-style/application-zip.png">
    

    Nothing changed

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited February 2014

    Did you empty the cache ini files files ?

    Do you have a thumbnails folder ?

    Do you have an uploads folder ?

    Is the image in the folder ?

    What is the full url to the image. Not the fileupload detect image. Remember that fileupload detect simply adds an icon of the file type.

    If you are using fileupload detect then that is where you need to search for the problem.

    please try this only using the normal fileupload plugin. disable the fileupload detect.

  • Options

    Yes, i emptied the browsers cache, the browsers history, and the .ini files in the cache folder but still no result; the url doesn't change in the console

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited February 2014

    That image up there is an image from the file upload detect plugin I think that is where you need to fix the urls to get the image.

  • Options

    Thanks. You pushed me in the right direction @vrijvlinder.
    I made absolute url in the following lines and now it shows the image:

    /* File Upload Detect - Auto Preview Method*/
        public static function AutoPreviewImage($FileName, $Default='misc.png'){
         $F='';
         $PreviewImage='http://www.webprofis.nl/plugins/FileUpload/images/'.C('Plugins.FileUpload.DetectLibrary','oxygen-style').'/'.$Default.'?'.$FileName;
         foreach(self::$FileIconDef As $Icon => $Formats)
            foreach ($Formats As $Format){
                $Format='.'.$Format;
                If(strcasecmp(substr($FileName, strlen($FileName) - strlen($Format)),$Format)===0 && substr_count($Format,'.')>substr_count($F,'.')){
                     $PreviewImage='http://www.webprofis.nl/plugins/FileUpload/images/'.C('Plugins.FileUpload.DetectLibrary','oxygen-style').'/'.$Icon;
                     $F=$Format;
                }
            }
        return $PreviewImage;
      }
    
  • Options
    meshugymeshugy Musician/Hacker ✭✭

    I have this exact same problem but I'm not using FileUpload Detect, but rather the regular FileUpload plugin v 1.7.1

    Does anyone know if this fix can be adapted to the the regular FileUpload plugin?

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    His problem was that the filetype image icons from file upload detect did not show . Not the thumbnails for atachments, is that what your problem is ?

    or is it that thumbnails don't show ?

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited February 2014

    @meshugy

    if the problem is the file type icon in fileupload plugin

    check this around line 579 of the class.fileupload.plugin.php

    $Url = Asset('/plugins/FileUpload/images/file.png');

    I made my own file for this :

  • Options
    meshugymeshugy Musician/Hacker ✭✭

    @vrijvlinder the problem @jackmaessen had was identical to mine. When you upload an attachment, the preview thumbnail does not appear. I had the same results as displayed in the images he posted above. No preview thumbnail in Firefox and an "X" in IE. I think the solution is the same (i.e. fixing the link to the thumbnail folder), but I don't know where to enter the hardlink to the preview thumbnails in the FileUpload.

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    No, jack's problem was the icon file type image that shows what kind of file it is.

    The link to the thumbnail folder is this

    /forum/uploads/thumbnails/FileUpload/31/dbafefb1215babeaed83b548501c6a.png

    There is nothing to change because it uses Path to file. Path to file is the the uploads folder.

    The problem might be with htaccess . It might need the full path to the image or change the structure of the url somehow .

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP
    /**
        * Create and display a thumbnail of an uploaded file.
        */
       public function UtilityController_Thumbnail_Create($Sender, $Args = array()) {
          $MediaID = array_shift($Args);
          if (!is_numeric($MediaID))
             array_unshift($Args, $MediaID);
          $SubPath = implode('/', $Args);
          $Name = $SubPath;
          $Parsed = Gdn_Upload::Parse($Name);
    
          // Get actual path to the file.
          $Path = Gdn_Upload::CopyLocal($SubPath);
          if (!file_exists($Path))
             throw NotFoundException('File');
    
  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    You can also see this in the media model

     public static function ThumbnailUrl(&$Media) {
          if (GetValue('ThumbPath', $Media))
             return Gdn_Upload::Url(ltrim(GetValue('ThumbPath', $Media), '/'));
    
          $Width = GetValue('ImageWidth', $Media);
          $Height = GetValue('ImageHeight', $Media);
    
          if (!$Width || !$Height) {
             if ($Height = self::ThumbnailHeight())
                SetValue('ThumbHeight', $Media, $Height);
             return '/plugins/FileUpload/images/file.png';
          }
    
          $RequiresThumbnail = FALSE;
          if (self::ThumbnailHeight() && $Height > self::ThumbnailHeight())
             $RequiresThumbnail = TRUE;
          elseif (self::ThumbnailWidth() && $Width > self::ThumbnailWidth())
             $RequiresThumbnail = TRUE;
    
          $Path = ltrim(GetValue('Path', $Media), '/');
          if ($RequiresThumbnail) {
             $Result = Url('/utility/thumbnail/'.GetValue('MediaID', $Media, 'x').'/'.$Path, TRUE);
          } else {
             $Result = Gdn_Upload::Url($Path);
          }
          return $Result;
       }
    
       public static function Url($Media) {
          static $UseDownloadUrl = NULL;
          if ($UseDownloadUrl === NULL)
             $UseDownloadUrl = C('Plugins.FileUpload.UseDownloadUrl');
    
    //      decho($Media);
    
          if (is_string($Media)) {
             $SubPath = $Media;
             if (method_exists('Gdn_Upload', 'Url'))
                $Url = Gdn_Upload::Url("$SubPath");
             else
                $Url = "/uploads/$SubPath";
          } elseif ($UseDownloadUrl) {
             $Url = '/discussion/download/'.GetValue('MediaID', $Media).'/'.rawurlencode(GetValue('Name', $Media));
          } else {
             $SubPath = ltrim(GetValue('Path', $Media), '/');
             if (method_exists('Gdn_Upload', 'Url'))
                $Url = Gdn_Upload::Url("$SubPath");
             else
                $Url = "/uploads/$SubPath";
          }
    
          return $Url;
       }
    
    }
    
  • Options
    meshugymeshugy Musician/Hacker ✭✭

    @vrijvlinder thanks, but I'm still not sure how to fix this. Seems that others have had this same issue: http://vanillaforums.org/discussion/comment/200969/#Comment_200969

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited February 2014

    @meshugy

    first you should check to see if you have a thumbnail folder in the uploads folder.

    As you can see from he link I posted the thumbnail folder needs to be inside the uploads folder not the fileupload folder in the uploads.

    the thumbnail folder can have a chmod of 666 . I don't think it needs to have higher..

    please give me a link to where I can observe this ? I will try to help get to the bottom is I can...

  • Options
    meshugymeshugy Musician/Hacker ✭✭

    @vrijvlinder I think I have a thumbnail folder. Every image that gets uploaded goes here: www.djangobooks.com/forum/uploads/FileUpload/

    there are loads of numbered folders in there and each seems to contain the uploaded image and a thumbnail

Sign In or Register to comment.