george Posted July 17, 2007 Share Posted July 17, 2007 I copied the code right off the tutorials here. And I am getting an Error 1 error. That's all it says is error 1. Could it be that php is trying to copy the file to a place where it has no permission to copy? And if so, is there any way I can tell it where to go?Client side <body><form action="filephp.php" id="fred" method="post" enctype="multipart/form-data"><label for="file">Filename:</label><input type="file" name="file" id="file" /> <br /><input type="submit" name="submit" value="Submit" /></form></body> Server side <?phpif ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; move_uploaded_file($_FILES["file"]["tmp_name"], $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; }?> And Error 1 is all it says. Link to comment Share on other sites More sharing options...
smartalco Posted July 17, 2007 Share Posted July 17, 2007 this isn't where your error is coming from but move_uploaded_file($_FILES["file"]["tmp_name"], $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; wont copy the file to 'upload/', its just gonna be in whatever directory your 'filephp.php' script is in, use move_uploaded_file($_FILES["file"]["tmp_name"], 'upload/' . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; Link to comment Share on other sites More sharing options...
george Posted July 17, 2007 Author Share Posted July 17, 2007 Progress, now php gives me Upload: Type: Size: 0 KbTemp file: Stored in: upload/So, still no file. Code the same as #1 above with the addition of <!-- MAX_FILE_SIZE must precede the file input field --> <input type="hidden" name="MAX_FILE_SIZE" value="30000" /> in the form. Why is it taking me all day to figure out how to upload a file from a browser input tag of type file. Link to comment Share on other sites More sharing options...
smartalco Posted July 17, 2007 Share Posted July 17, 2007 your original error (error 1) ment that the file was too bigit hasn't got anything out of your form, it would be helpful if we could see exactly what your code is, from what you have posted I have no idea what is wrong Link to comment Share on other sites More sharing options...
george Posted July 17, 2007 Author Share Posted July 17, 2007 Closer, had the form's input type file named differently from the php $_FILEDS[ array element name. Link to comment Share on other sites More sharing options...
george Posted July 17, 2007 Author Share Posted July 17, 2007 Call to undefined function move_uploaded_userfile() IS there a php.ini setting for this or something? Link to comment Share on other sites More sharing options...
george Posted July 17, 2007 Author Share Posted July 17, 2007 it would be helpful if we could see exactly what your code is, from what you have posted I have no idea what is wrongMy code is in post 1 of this thread. I made a special tiny program just to get this part right before I integrate it in with my project. I usually do this when I am up against a wall. Link to comment Share on other sites More sharing options...
justsomeguy Posted July 17, 2007 Share Posted July 17, 2007 You can find file upload error codes here:http://www.php.net/manual/en/features.file-upload.errors.phpAlso, move_uploaded_userfile is not a function, it is move_uploaded_file. Link to comment Share on other sites More sharing options...
G3L0 Posted September 3, 2007 Share Posted September 3, 2007 hello i use upload script from w3schools. i wan to upload a .csv file, in my computer i get application/vnd.ms-excel. but when i try in my friend's computer, the type is application/octet-stream. Anyone know why... thx Link to comment Share on other sites More sharing options...
Synook Posted September 3, 2007 Share Posted September 3, 2007 Different browsers and different operating systems will send different MIME types to the server, you will just have to cater for them all. Does he have a mac? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.