Jump to content

Recommended Posts

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>

<?php
if(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 problem
San
Link to comment
https://forums.phpfreaks.com/topic/11180-move_upload_file-problem/
Share on other sites

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
[!--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>


<?php
if(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]
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.