Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

spaces in filename cookie

Status
Not open for further replies.

partymong

Programmer
Nov 5, 2003
39
0
0
GB
Hi All,
I have a problem I hope you can help me with...

I am running windows, IIS5.

I have an upload form, where the user is allowed to browse for a file to upload.($_FILES['file1']['name']) I then use a php script to put the filename that they choose in a cookie and retrieve it later..

My problem occurs when there is a space in the filename. PHP automatically uses the 'application/x- media type' and therfore replaces spaces with +

I have tried to use rawurlencode before I add the filename to the cookie...but it I still get +'s

Is there an easy way I can maybe strip the filename($_FILES['file1']['name'])of spaces before it gets uploaded?

Any ideas?

Thanks for your help!

Regards,
P
 
$filename = str_replace (" ", "_", $filename);

but perhaps it's easier to store the filepath serverside in mysql and only put the id of the record in a cookie. or better save the hostname and/or ip adress as an extra check in case cookies are gone

 
Hi Hos2,
Thanks that works great!
I only temporarily store the cookie, the next script adds it to a database.

Thankyou for your help!

P
 
Hey partymong,
If your only storing data temperarily, then perhaps setting a session variable would be another option. That way it doesn't matter if the user's browser has cookies disabled. Just a suggestion.
 
Hi Westbury,
I'm new to php...
What I need to do is transfer the filename between php and asp...(don't ask...)

I have found that the only way to do this is via a cookie..

Any other suggestions would be appreciated...

Ideally I would like to add the filename directly to MSSQL server...via php....but I don't believe that the MSSQL server functions are bundled in the general distribution...

Any help would be appreciated....

Thanks

P
 
Hi All,
Ok ignore my post about mssql....

I've got it working....

A note of caution for anyone else having problems with MSSQL and php...

You must make sure you have the 'right' php_mssql.dll in the php directory....

P
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top