Jump to content

[SOLVED] Only First Entry In Array Being Uploaded To Server


dlebowski

Recommended Posts

With the code below, I can get the first Image in my array to upload correctly.  I cannot get the others to upload after that.  Can someone tell me what is wrong?  The array is being generated correctly, but nothing is being grabbed other than first entry.

 

$ImageAuctionDate=$_POST['SelectLotAuctionDate'];


echo 'Upload result:<br>'; 

$uploaddir = dirname($_SERVER['SCRIPT_FILENAME'])."/images/".$ImageAuctionDate."/";

$target_encoding = "ISO-8859-1";
echo '<pre>';
if(count($_FILES) > 0)
{
$arrfile = pos($_FILES);
$uploadfile = $uploaddir . iconv("UTF-8", $target_encoding,basename($arrfile['name']));

if (move_uploaded_file($arrfile['tmp_name'], $uploadfile))
   echo "File is valid, and was successfully uploaded.\n";
}
else
echo 'No files sent. Script is OK!'; 

echo 'Here is some more debugging info:';
print_r($_FILES);

echo "</pre>";
}

 

Result:

File is valid, and was successfully uploaded.
Here is some more debugging info:Array
(
    [LotImage1] => Array
        (
            [name] => DSCF3088.JPG
            [type] => image/jpeg
            [tmp_name] => /tmp/phpEb0Wvs
            [error] => 0
            [size] => 111168
        )

    [LotImage2] => Array
        (
            [name] => DSCF3092.JPG
            [type] => image/jpeg
            [tmp_name] => /tmp/phpjYo1N6
            [error] => 0
            [size] => 111525
        )

    [LotImage3] => Array
        (
            [name] => DSCF3116.JPG
            [type] => image/jpeg
            [tmp_name] => /tmp/phpagCTNP
            [error] => 0
            [size] => 113969
        )

    [LotImage4] => Array
        (
            [name] => DSCF3155.JPG
            [type] => image/jpeg
            [tmp_name] => /tmp/phpD3Et3D
            [error] => 0
            [size] => 112006
        )

    [LotImage5] => Array
        (
            [name] => DSCF3088.JPG
            [type] => image/jpeg
            [tmp_name] => /tmp/phpRKJrkw
            [error] => 0
            [size] => 111168
        )

    [LotImage6] => Array
        (
            [name] => DSCF3187.JPG
            [type] => image/jpeg
            [tmp_name] => /tmp/phpujkAkt
            [error] => 0
            [size] => 107119
        )

)

Link to comment
Share on other sites

Here is what I finally had to do to take care of it.  Works great now.

 

foreach($_FILES as $files )
{
        
        $uploaddir = dirname($_SERVER['SCRIPT_FILENAME'])."/images/".$LotAuctionDate."/";
$arrfile = $files;
$uploadfile = $uploaddir . iconv("UTF-8", $target_encoding,basename($arrfile['name']));

if (move_uploaded_file($arrfile['tmp_name'], $uploadfile))
   echo "File is valid, and was successfully uploaded.\n";
}

Link to comment
Share on other sites

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.