ainoy31 Posted June 5, 2007 Share Posted June 5, 2007 I have a simple page to upload files. Here is the form page: <form action="Uploader.php" method="post"><br> Type (or select) Filename: <input type="file" name="uploadFile"> <input type="hidden" name="MAX_FILE_SIZE" value="25000" /> <input type="submit" value="Upload File"> </form> Here is the PHP file to process this: if ( move_uploaded_file ($_FILES['uploadFile'] ['tmp_name'], "../uploads/{$_FILES['uploadFile'] ['name']}") ) { print '<p> The file has been successfully uploaded </p>'; } else { switch ($_FILES['uploadFile'] ['error']) { case 1: print '<p> The file is bigger than this PHP installation allows</p>'; break; case 2: print '<p> The file is bigger than this form allows</p>'; break; case 3: print '<p> Only part of the file was uploaded</p>'; break; case 4: print '<p> No file was uploaded</p>'; break; } } I am not getting any error messages or file upload to my uploads directory. Any suggestion would be appreciated. thx. AM Link to comment https://forums.phpfreaks.com/topic/54311-upload-file/ Share on other sites More sharing options...
The Little Guy Posted June 5, 2007 Share Posted June 5, 2007 Try this: <form action="Uploader.php" method="post" enctype="multipart/form-data"> Link to comment https://forums.phpfreaks.com/topic/54311-upload-file/#findComment-268543 Share on other sites More sharing options...
ainoy31 Posted June 5, 2007 Author Share Posted June 5, 2007 Can anyone tell me what this means? Because I have the uploads folder in the same folder as my website. Warning: move_uploaded_file(../uploads/Test file upload.doc) [function.move-uploaded-file]: failed to open stream: No such file or directory in W:\www\Uploader.php on line 11 thx. AM Link to comment https://forums.phpfreaks.com/topic/54311-upload-file/#findComment-268566 Share on other sites More sharing options...
The Little Guy Posted June 5, 2007 Share Posted June 5, 2007 Try this: <?php if ( move_uploaded_file ($_FILES['uploadFile'] ['tmp_name'], "uploads/{$_FILES['uploadFile'] ['name']}") ) ?> Edit: Also make sure the directory exists, move_uploaded_file will NOT create a directory if it is inexistant. Link to comment https://forums.phpfreaks.com/topic/54311-upload-file/#findComment-268574 Share on other sites More sharing options...
ainoy31 Posted June 5, 2007 Author Share Posted June 5, 2007 much love to you and your family! Link to comment https://forums.phpfreaks.com/topic/54311-upload-file/#findComment-268577 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.