Search the Community
Showing results for tags 'uploading a file'.
-
!doctype html> <html lang="en"> <head> <meta charset="utf-8"> </head> <body> <?php if ($_SERVER['REQUEST_METHOD'] == 'POST'){ if (move_uploaded_file($_FILES['the_file']['tmp_name'],"C:\uploads\{$_FILES['the_file']['name']}")) { print '<p>your file has been uploaded.</p>'; }else { print '<p style="color:red;">Your file couldnot be uploaded because :'; switch ($_FILES['the_file']['error']) { case 1: print 'the file excceeds the upload_max-file size setting in php.oni'; break; case 2: print 'The file exceeds the max-FILE_SIZE SETTING IN THE HTML FORM'; break; case 3: print 'The file was only partially uploaded'; break; case 4: print 'No fil was uploaded'; break; case 6: print 'The temporary folder does not exixts,'; break; default: print 'something unforeseen happend'; break; } print '.</p>'; } } ?> <form action="upload_file.php" enctype="multipart/form-data" method="post"> <p> Upload a file using this form:</p> <input type="hidden" name="MAX_FILE_SIZE" value="300000"> <p><input type="file" name="the_file"></p> <p><input type="submit" name="submit" value="upload this file"></p> </form> </body> </html> when i try to run this i get this error: Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\xampp\htdocs\PHPexamples\chapter11\upload_file.php on line 10 not understanding move_uploaded_file() function here. if i am right, i should be able to upload any file from PC and load it to uploads folder? its bit confusing and not clear ,,page 318-320 .. i didnt even get html form to upload any file. i had saved jpg file in some different directory and wanted to upload that and move it to uploads folder.. please some one explain. thank you.