Menu

Spaces in file upload link

Help
Bullmax
2007-08-19
2013-06-03
  • Bullmax

    Bullmax - 2007-08-19

    I have searched for an answer but could not find one.  When I receive the email from a file upload, if the file has spaces in it, the link is broken.

    Example:
    http://www.url.com/forums/feedback/use/picture/files/11_45_31_ygpc670xx8 (100 x 100).jpg

    Only this part is clickable: http://www.url.com/forums/feedback/use/picture/files/11_45_31_ygpc670xx8

    Thanks for any help.

     
    • TNTEverett

      TNTEverett - 2007-08-20

      File names can be tricky because it depends on how your host allows file names to be stored. 
      The best thing to do is conform the file names to something more commonly acceptable.  In the form you allow people to browse and provide file names of any sort.  In the process.php file you must then modify the file names to somthing that does not include spaces or special characters.  Spaces are the most common so start with that.  If you find someone has trouble with other file names you can add other filters as required. 

      Find the line of code in the process.php file that contains the post for the variable representing the filename, then add the following:
      $fn_var=trim($fn_var);
      $fn_var=str_replace(' ','_',$fn_var);

      Where $fn_var is the File Name VARiable you are using in your process.php.

      The following link explains the use of trim().
      http://us3.php.net/trim
      The following link explains the use of str_replace().
      http://us3.php.net/str_replace

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.