Uploading image - extra backslashes on my webhost!?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Matt Phelps
Forum Commoner
Posts: 82
Joined: Fri Jun 14, 2002 2:05 pm

Uploading image - extra backslashes on my webhost!?

Post by Matt Phelps »

I'm creating an upload script so that users can upload images of themselves into a directory. Unfortunately it doesn't seem to work on my webhosts server (LINUX I think.)

I coded it on my laptop which is a Windows ME machine but I don't understand why it works under windows but not under Linux.

The error message I get is:

Warning: Unable to open 'C:\\WINDOWS\\Desktop\\myphoto.jpg' for reading: No such file or directory


The line of code for the upload selector is just a browse input box:
<input type=file name=driverimage size=30>
and then:

Code: Select all

if (!$driverimage == "")
&#123;
copy($driverimage, "$abpath/$imagename");
&#125;
Where on earth are those extra backslashes coming from and how do I get rid of them and make it upload my image!!
Geschi
Forum Newbie
Posts: 21
Joined: Wed Jul 10, 2002 3:21 am
Location: Germany

Post by Geschi »

Echo out your $abpath and $imagename and maybe even explode() them and test how this takes effect on your Linux comp.
Matt Phelps
Forum Commoner
Posts: 82
Joined: Fri Jun 14, 2002 2:05 pm

Post by Matt Phelps »

Well I echoed them out and they were just as expected and as defined in the script.
MattF
Forum Contributor
Posts: 225
Joined: Sun May 19, 2002 9:58 am
Location: Sussex, UK

Post by MattF »

You are missing out a step or two of file uploading, when a file is uploaded it is not put in the same position as it had one the uploaders computer, for example if I load C:\autoexec.bat it will not be on the linux server as C:\autoexec.bat especiallly as linux servers don't have partitions like that. You need to find out the temporary file name of the uploaded file and then copy using that file name. See more info here: http://www.php.net/manual/en/features.file-upload.php
Post Reply