URL Encode the download link?

All support enquiries for DFH go in here...

URL Encode the download link?

Postby test » Sat Nov 26, 2011 12:41 am

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! :)
test
Standard Member
 
Posts: 37
Joined: Tue Apr 05, 2011 1:21 pm

Re: URL Encode the download link?

Postby SamEA » Tue Nov 29, 2011 4:38 am

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");
SamEA,
DaddyScripts' Admin & Developer.

Require a PHP or general IT freelancer? Don't hesitate to PM me.
User avatar
SamEA
Site Admin
 
Posts: 1165
Joined: Sat Feb 19, 2011 7:51 pm

Re: URL Encode the download link?

Postby test » Tue Nov 29, 2011 9:32 am

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.
test
Standard Member
 
Posts: 37
Joined: Tue Apr 05, 2011 1:21 pm

Re: URL Encode the download link?

Postby SamEA » Wed Nov 30, 2011 5:28 pm

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.
SamEA,
DaddyScripts' Admin & Developer.

Require a PHP or general IT freelancer? Don't hesitate to PM me.
User avatar
SamEA
Site Admin
 
Posts: 1165
Joined: Sat Feb 19, 2011 7:51 pm

Re: URL Encode the download link?

Postby test » Wed Nov 30, 2011 9:01 pm

PM sent, thanks. :)
test
Standard Member
 
Posts: 37
Joined: Tue Apr 05, 2011 1:21 pm

Re: URL Encode the download link?

Postby SamEA » Thu Dec 01, 2011 12:48 am

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.
SamEA,
DaddyScripts' Admin & Developer.

Require a PHP or general IT freelancer? Don't hesitate to PM me.
User avatar
SamEA
Site Admin
 
Posts: 1165
Joined: Sat Feb 19, 2011 7:51 pm

Re: URL Encode the download link?

Postby test » Thu Dec 01, 2011 9:20 am

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.
test
Standard Member
 
Posts: 37
Joined: Tue Apr 05, 2011 1:21 pm

Re: URL Encode the download link?

Postby SamEA » Fri Dec 02, 2011 3:44 pm

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
SamEA,
DaddyScripts' Admin & Developer.

Require a PHP or general IT freelancer? Don't hesitate to PM me.
User avatar
SamEA
Site Admin
 
Posts: 1165
Joined: Sat Feb 19, 2011 7:51 pm


Return to Daddy's File Host v1.X

Who is online

Users browsing this forum: No registered users and 25 guests

cron