/    Sign up×
Community /Pin to ProfileBookmark

Problem uploading images on Firefox

Hi,,

for some reason my image upload code only works on IE,, I have a form from where the users can upload up to 5 images if they want, on the form page I have 5 identical inputs so the user can attach the images:
They are all like this: <input type=”file” name=”images[]” size=”45″>

then the form calls a page that uploads the images::

for ($i=0;$i<count($images);$i++) {
.
.
.
copy($images[$i],$path);
}

this code only works on IE and not on FireFox, on FireFox it only uploads the first image and not the others that the user might have attached. Does someone knows why, and maybe have a suggestion of a solution on how I could make this work on FireFox as well? Thanks

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@stephan_gerlachFeb 20.2007 — instead of using images[] as name just try using different names i.e. image1, image2, image3, image4, image5

Im quite sure this will work
Copy linkTweet thisAlerts:
@bokehFeb 20.2007 — instead of using images[][/QUOTE]That's bogus! [B]images[][/B] is perfectly valid in this context.

[code=php]$FieldName = 'images';
$UploadsFolder = 'uploads/';
$output = '';

foreach($_FILES[$FieldName]['error'] as $k => $v)
{
if(0 === $v)
{
if(file_exists($Filename = $UploadsFolder . $_FILES[$FieldName]['name'][$k]))
while(50 > ++$v and file_exists(
$Filename=$UploadsFolder.preg_replace('/(?=.[^.]+$)/','-'.$v,$_FILES[$FieldName]['name'][$k])
));
50 > $v or die('Please rename ' . $_FILES[$FieldName]['name'][$k]);
if(move_uploaded_file($_FILES[$FieldName]['tmp_name'][$k], $Filename))
{
$output .= "<p><em>{$_FILES[$FieldName]['name'][$k]}</em> saved OK!</p>n";
}
}
}
$output or $output = '<p>No files were saved</p>';
echo $output;[/code]
Copy linkTweet thisAlerts:
@Marlon_BrauthorFeb 21.2007 — Thanks for the help bokeh, although your solution seems too much for my simple upload code I´ll take a better look at it, and see what I can use.
×

Success!

Help @Marlon_Br spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...