Page 1 of 1

Uploading image - extra backslashes on my webhost!?

Posted: Thu Aug 15, 2002 9:39 am
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!!

Posted: Thu Aug 15, 2002 9:51 am
by Geschi
Echo out your $abpath and $imagename and maybe even explode() them and test how this takes effect on your Linux comp.

Posted: Thu Aug 15, 2002 9:57 am
by Matt Phelps
Well I echoed them out and they were just as expected and as defined in the script.

Posted: Thu Aug 15, 2002 12:07 pm
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