Upload File Error

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
mattmcb
Forum Commoner
Posts: 27
Joined: Sun Jan 25, 2004 3:34 pm

Upload File Error

Post 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!
Revan
Forum Commoner
Posts: 83
Joined: Fri Jul 02, 2004 12:37 am
Location: New Mexico, USA
Contact:

Post by Revan »

Windows paths, need to be in double slashs, I believe.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

windows also supports /, fe: $path = 'c:/winnt/whatever.txt';

makes things a lot easier :)
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post 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....
Post Reply