Page 1 of 1

Upload File Error

Posted: Thu May 05, 2005 3:51 pm
by mattmcb
I have some real simple code to upload a file and it it not working... any suggestions?

Form:

Code: Select all

<b>Select your File: </b><input type="file" name="userfile">  <input type="hidden" name="MAX_FILE_SIZE" value="24000">
Process Form:

Code: Select all

copy ($userfile, "/batch/".$userfile_name) or die ("Could not copy");
$file = $userfile_name;
Error:
Warning: copy(C:\\Documents and Settings\\Administrator\\Desktop\\orders.csv): failed to open stream: No such file or directory in /home/buywell/public_html/bulk_order_process.php on line 14
Could not copy
Look at the local file path, why would \\ be showing up instead of \. I'm thinking that's the problem but how could I replace \\ with \ to give it a try. Php gets funny when you do \' or \".

Thanks!

Posted: Thu May 05, 2005 4:04 pm
by Revan
Windows paths, need to be in double slashs, I believe.

Posted: Thu May 05, 2005 4:39 pm
by timvw
windows also supports /, fe: $path = 'c:/winnt/whatever.txt';

makes things a lot easier :)

Posted: Fri May 06, 2005 3:42 am
by phpScott
you might also want to look at $_FILE[] super global for testing if the file is uploaded, temparary name, actual name, file type, etc....