Page 1 of 1

URL Encode the download link?

PostPosted: Sat Nov 26, 2011 12:41 am
by test
It seems that when someone uploads a file with Hebrew characters to my server, when people download it with Chrome, or Firefox, they seem to download the exact file with the same Hebrew filename. The problem occures when they use IE. They see the filename in Gibberish. Even I see in Gibberish with IE, even though I'm using a Hebrew operating system.

A quick Google search (thanks to my host), has brought up these results:
http://drupal.org/node/766392

http://blooberry.com/indexdot/html/topi ... coding.htm


It seems that this is a quite known problem.

Thanks for your help! :)

Re: URL Encode the download link?

PostPosted: Tue Nov 29, 2011 4:38 am
by SamEA
You could use the MD5 function to encrypt your filename's URL.

Open ./upload.php

Find:
Code: Select all
$rand2=("$fancyurl$filename");

Add after that line:
Code: Select all
$rand2 = md5($rand2);


Find:
Code: Select all
fwrite($filelist, $rand2 ."|". $filename ."|". $passkey ."|". $userip ."|". $time."|0|".$description."|".$passwerd."|".$cat."|".$_POST['pprotect'] ."|" .$_SESSION['user'] ."|\n");

And replace with:
Code: Select all
fwrite($filelist, $rand2 ."|". md5($filename) ."|". $passkey ."|". $userip ."|". $time."|0|".$description."|".$passwerd."|".$cat."|".$_POST['pprotect'] ."|" .$_SESSION['user'] ."|\n");

Re: URL Encode the download link?

PostPosted: Tue Nov 29, 2011 9:32 am
by test
Nope, it doesn't work. The filename in the url is like 1409dac091490fac9813, and when I try to download it with Internet Explorer, I still can't read the Hebrew characters, it's all gibberish.

Re: URL Encode the download link?

PostPosted: Wed Nov 30, 2011 5:28 pm
by SamEA
Please PM or post your script's URL in order to investigate this issue further. Furthermore, also provide a link to the Hebrew file name. Thank you.

Re: URL Encode the download link?

PostPosted: Wed Nov 30, 2011 9:01 pm
by test
PM sent, thanks. :)

Re: URL Encode the download link?

PostPosted: Thu Dec 01, 2011 12:48 am
by SamEA
Thank you for your PM. I have managed to download the filename via the browser Google Chrome and Internet Explorer without encountering any problems. Please make sure you have the latest version of IE. Also, I advise you try to downloading the file using another PC? Thank you.

Re: URL Encode the download link?

PostPosted: Thu Dec 01, 2011 9:20 am
by test
It works fine in Chrome, and in IE the filename is different.

I have IE9, and my host also tried to download the file via IE, and he confirmed this issue...

I have no problems downloading the file, I have problems with its name, when you try to save it in Internet Explorer.

Re: URL Encode the download link?

PostPosted: Fri Dec 02, 2011 3:44 pm
by SamEA
The download in IE worked fine with me, however if this problem at times occurs with different browsers, use the above MD5 encryption format. This will encrypt the filename to letters and numbers. I have adjusted the code slighty than the one posted previously, please look at my previous post.

Note: The above method will encode the filename leading to the filename being renamed and thus losing the file extension (the user will have to add a file extension to each file).

I advise you to add an IF statement to check for unknown characters or an IF statement to force the user to input a filename with english-only characters.

Example: http://stackoverflow.com/questions/6303 ... -in-string