konflikt Posted May 13, 2011 Share Posted May 13, 2011 I am having trouble getting my upload file to work... Form HTML: <form action="" method="POST"> <input type="file" name="file" /> <input type='"submit" name="upload" value="Upload" /> </form> PHP: if($_POST["upload_avatar"]){ $upload_path = "images/users/"; $file = $_FILES["file"]["name"]; $extension_types = array("gif","jpg","jpeg","png"); if($file){ $filename = stripslashes($_FILES["file"]["name"]); $extension = getExtension($filename); $extension = strtolower($extension); $size = filesize($_FILES["file"]["tmp_name"]); if(in_array($extension, $extension_types)){ if($size <= $max_file_size){ $file_search = glob($upload_path . strtolower($username) . '*'); array_map("unlink", $file_search); $file_name = $upload_path . strtolower($username) . "." . $extension; $copied = copy($_FILES["file"]["tmp_name"], $file_name); if (!$copied){ $r_error = "Upload has failed"; } } else{$r_error = "File too big";} } else{$r_error = "Unknown file extension";} } else{$r_error = "No file chosen";} } Every time, it gives me the "No File Chosen" error. It doesn't seem to be actually uploading the file... I hope this isn't just some stupid thing I am looking over, can someone help me? Quote Link to comment https://forums.phpfreaks.com/topic/236282-uploading-file-problem/ Share on other sites More sharing options...
requinix Posted May 13, 2011 Share Posted May 13, 2011 You need to add a enctype="multipart/form-data" to your . Quote Link to comment https://forums.phpfreaks.com/topic/236282-uploading-file-problem/#findComment-1214770 Share on other sites More sharing options...
konflikt Posted May 13, 2011 Author Share Posted May 13, 2011 Oh... yes.... thanks xD Quote Link to comment https://forums.phpfreaks.com/topic/236282-uploading-file-problem/#findComment-1214771 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
× Pasted as rich text. Restore formatting
Only 75 emoji are allowed.
× Your link has been automatically embedded. Display as a link instead
× Your previous content has been restored. Clear editor
× You cannot paste images directly. Upload or insert images from URL.