superprg Posted June 4, 2006 Share Posted June 4, 2006 Can someone please tell me why this wont work?[a href=\"http://facebuddies.com/php_upload/move_upload/1.php\" target=\"_blank\"]http://facebuddies.com/php_upload/move_upload/1.php[/a]Here is the code[code]<form action="" method="post" enctype="multipart/form-data"><p>Pictures:<input type="file" name="pictures[]" /><input type="file" name="pictures[]" /><input type="file" name="pictures[]" /><input type="submit" value="Send" /></p></form> <?phpif(isset($_FILES['pictures']['error'])){ foreach ($_FILES["pictures"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["pictures"]["tmp_name"][$key]; $name = $_FILES["pictures"]["name"][$key]; move_uploaded_file($tmp_name, "data/$name"); } }}?> [/code]The strange thing is same code works on my local machine so I am sure this must be some configuration problemSan Quote Link to comment https://forums.phpfreaks.com/topic/11180-move_upload_file-problem/ Share on other sites More sharing options...
superprg Posted June 4, 2006 Author Share Posted June 4, 2006 The problem is here$_FILES["pictures"]["tmp_name"][$key]But still dont know how to resolve itCan anyone help?? Quote Link to comment https://forums.phpfreaks.com/topic/11180-move_upload_file-problem/#findComment-41842 Share on other sites More sharing options...
homchz Posted June 4, 2006 Share Posted June 4, 2006 what is it not doing, how large is the file, If it works on your local machine but not on your live server, you may need to talk to your host. Most shared hosts to not allow larger than 2MB uploads on there systems to prevent lag. So it might not be a code issue.Just a thought Quote Link to comment https://forums.phpfreaks.com/topic/11180-move_upload_file-problem/#findComment-41862 Share on other sites More sharing options...
redarrow Posted June 4, 2006 Share Posted June 4, 2006 [!--quoteo(post=380036:date=Jun 4 2006, 09:33 PM:name=homchz)--][div class=\'quotetop\']QUOTE(homchz @ Jun 4 2006, 09:33 PM) [snapback]380036[/snapback][/div][div class=\'quotemain\'][!--quotec--]what is it not doing, how large is the file, If it works on your local machine but not on your live server, you may need to talk to your host. Most shared hosts to not allow larger than 2MB uploads on there systems to prevent lag. So it might not be a code issue.Just a thought[/quote]You got to use the correct form format heres an example ok.[code]<!-- The data encoding type, enctype, MUST be specified as below --><form enctype="multipart/form-data" action="__URL__" method="POST"> <!-- MAX_FILE_SIZE must precede the file input field --> <input type="hidden" name="MAX_FILE_SIZE" value="30000" /> <!-- Name of input element determines name in $_FILES array --> Send this file: <input name="userfile" type="file" /> <input type="submit" value="Send File" /></form>[/code]Just set the file size ok.[code]<form enctype="multipart/form-data" action="" method="POST"><input type="hidden" name="MAX_FILE_SIZE" value="30000" /><input name="pictures[]" type="file" /><input name="pictures[]" type="file" /><input name="pictures[]" type="file" /><input type="submit" value="Send File" /></form><?phpif(isset($_FILES['pictures']['error'])){ foreach ($_FILES["pictures"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["pictures"]["tmp_name"][$key]; $name = $_FILES["pictures"]["name"]["key"]; move_uploaded_file($tmp_name, "data/$name"); } }}?> [/code] Quote Link to comment https://forums.phpfreaks.com/topic/11180-move_upload_file-problem/#findComment-41863 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.