Hey all I have made a basic form allowing a user to upload an image underneath 824000 bytes. However for some reason I can’t seem to get it to upload any files, I really am not sure what I am doing wrong. Some help would be great …
here is my code…
<?php /*Check if the form has been submitted*/ if ($SERVER['REQUEST_METHOD'] == 'POST') { // Check for an upload file if (isset($_FILES['upload'])) { //validate the type should be JPEG or PNG $allowed = array ('image/pjep', 'image/JPG', 'image/jpeg', 'image/x-PNG', 'image/PNG', 'image/png', 'image/x-png'); if (in_array($_FILES['upload']['type'], $allowed)) { //move the file over if (move_uploaded_file($_FILES['upload']['tmp_name'], "../uploads/{$_FILES['upload']['name']}")) { echo 'The file has been uploaded!
'; } //end of move } else { //invalid type echo 'Please upload a JPEG or PNG Image.
'; } } // End of isset //Check for an error if ($_FILES['upload']['error'] > 0) { echo 'The File Could Not Be Uploaded Because: '; switch ($_FILES['upload']['error']) { case 1: print 'the file exceeds the upload_max_filesize setting in php.ini'; case 2: print 'The file exceeds the MAX_FILE_SIZE setting in the HTML form'; case 3: print 'The file was only partially uploaded.'; case 4: print 'No file was uploaded'; break; case 6: print 'No temporary folder was available'; case 7: print 'Unable to write to disk'; case 8: print 'File upload stopped'; break; default: print 'A system error occured'; break; } // end of switch print '
'; } // End of error IF // Delete the file if it still exists if (file_exists ($_FILES['upload']['tmp_name']) && is_file ($_FILES['upload']['tmp_name'])) { unlink ($_FILES['upload']['tmp_name']); } } // End of submitted conditional ?> Select a JPG or PNG image of 2MB or smaller to be uploaded:File: