ohdang888 Posted July 31, 2008 Share Posted July 31, 2008 here's my code: i'm not getting any PHP errors I don't think the file is even getting uploaded. Because when i print_r($_FILES) i'm just getting "array( )", so its empty any ideas?Thanks <br><form id="Upload" action="chapter.php?id=<?php echo $id ?>&action=pic" enctype="multipart/form-data" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="3000" /> <input id="file" type="file" name="file"> <input type="submit" name="pic_submit" value="Upload"></form><br> <?php } if($_GET['action'] == "pic"){ print_r($_FILES); $name = $_FILES["file"]["name"]; $type = $_FILES["file"]["type"]; $size = ($_FILES["file"]["size"] / 1024); $uploaded_file= basename($_FILES["file"]["tmp_name"]); echo $type; echo "name: $name"; if($type == ".gif" or $type == ".jpg" or $type == ".png" or $type == ".jpeg"){ //do nothing }else{ echo "Invalid file type -- you tried to upload a $type file<br>"; $stop = "yes"; } if($size >= 1500){ echo "File must be less than 1.5 megabytes<br>"; $stop = "yes"; } if ($_FILES["file"]["error"] > 0){ echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; $stop = "yes"; } if($stop != "yes"){ $new_name = "chap_pics/".$chapter_id.$type; if(move_uploaded_file($uploaded_file, $new_name)){ echo "<b><br>File uploaded!</b><br>"; echo $new_name; }else{ echo "<br>File upload failed.<br>"; } }else{ echo "File upload stopped.<br>"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/117641-deal-with-uploaded-files/ Share on other sites More sharing options...
PFMaBiSmAd Posted July 31, 2008 Share Posted July 31, 2008 An empty $_FILES array either means uploads are not enabled in php.ini or you have exceeded the post_max_size setting, in which case the $_POST array will be empty as well. Quote Link to comment https://forums.phpfreaks.com/topic/117641-deal-with-uploaded-files/#findComment-605114 Share on other sites More sharing options...
ohdang888 Posted August 1, 2008 Author Share Posted August 1, 2008 ok so now $_FILES is full, but its still not uploading. Quote Link to comment https://forums.phpfreaks.com/topic/117641-deal-with-uploaded-files/#findComment-605730 Share on other sites More sharing options...
ShaunO Posted August 1, 2008 Share Posted August 1, 2008 Make sure the chap_pics directory is writable by your webserver. (chmod 777) Quote Link to comment https://forums.phpfreaks.com/topic/117641-deal-with-uploaded-files/#findComment-605744 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.