Jump to content


Photo

move_upload_file problem


  • Please log in to reply
3 replies to this topic

#1 superprg

superprg
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 04 June 2006 - 06:40 PM

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

<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");
      }
   }
}
?>  



The strange thing is same code works on my local machine so I am sure this must be some configuration problem
San

#2 superprg

superprg
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 04 June 2006 - 08:20 PM

The problem is here
$_FILES["pictures"]["tmp_name"][$key]
But still dont know how to resolve it
Can anyone help??

#3 homchz

homchz
  • Members
  • PipPipPip
  • Advanced Member
  • 93 posts
  • LocationLee, New Hampshire

Posted 04 June 2006 - 09:33 PM

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

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 04 June 2006 - 09:40 PM

[!--quoteo(post=380036:date=Jun 4 2006, 09:33 PM:name=homchz)--][div class=\'quotetop\']QUOTE(homchz @ Jun 4 2006, 09:33 PM) View Post[/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.


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


Just set the file size ok.

<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");
      }
   }
}
?> 


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users