Special Characters in File upload

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
dharprog
Forum Contributor
Posts: 126
Joined: Fri Oct 27, 2006 12:20 am

Special Characters in File upload

Post by dharprog »

Hi All,

This is new situation for me how to handle the Special characters in File upload before sending to either php file which handles the file.

I want to change the file name or remove the special characters like single quote (') or Double quote like ("), &, # as i am getting the word broken to php page.

I just want to make it in the client side only as i am using ajax and while sending the request to php the url is breaking.

So please anyone guide me in this situation how to handle this.

Thanks and regards,
DharProg
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Special Characters in File upload

Post by AbraCadaver »

Use escape() on that portion of the URL. It encodes the special characters for use in a URL. It's similar to the PHP urlencode() function.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Special Characters in File upload

Post by Eran »

escape() should be avoided for URLs. Use encodeURIComponent() instead
http://xkr.us/articles/javascript/encode-compare/
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Special Characters in File upload

Post by AbraCadaver »

pytrin wrote:escape() should be avoided for URLs. Use encodeURIComponent() instead
http://xkr.us/articles/javascript/encode-compare/
Good to know, thanks!
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
dharprog
Forum Contributor
Posts: 126
Joined: Fri Oct 27, 2006 12:20 am

Re: Special Characters in File upload

Post by dharprog »

Hi All,

Thanks for your support but i could not find the url where it is generating as it is ajaxupload.js file from Jquery.

How to find and where can i see the url to apply escape?

Please guide me.

Thanks and regards,
DharProg.
User avatar
dharprog
Forum Contributor
Posts: 126
Joined: Fri Oct 27, 2006 12:20 am

Re: Special Characters in File upload [Solved]

Post by dharprog »

Hi All,

It is solved with the following solution changing the php.ini setting:

magic_quotes_gpc = off.

If there is any other solution is there please provide me without changing the php.ini.

Thanks for all your support,

Dharprog
Post Reply