/    Sign up×
Community /Pin to ProfileBookmark

Question about multiple Uploads

I have a code that simply uploads an image to a certain file. Easy said easy done. My question is this 1 is it possible to upload multiple images for one product. 2 can I make PHP take a photo and re size it to say 150×150 for small and 250×250 for large? 3 would it be better to just show those images by themselves or make them into a slide show?

I can show the code I have if that will help explain what I need.

Thanks in advance.

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@stoneman30Mar 07.2011 — Yes, it is possible to upload multiple images at one time. You can find that on the PHP manual http://php.net/manual/en/features.file-upload.multiple.php.

As far as resizing images, I assume you mean creating thumbnails on upload. If so, you can also resize images with PHP, but you will need to use a special extension called GD to do it. Go to php.net and install GD if you don't already have it. Then, check out this site for resizing images. It has all of the code written for you. All you have to do is write a few lines of code to make it work: http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php.

As far as your third question is concerned, that is more subjective. I'd have to see the site to give you my opinion.
Copy linkTweet thisAlerts:
@shutterbugauthorMar 11.2011 — Ill try that and see if it works.
Copy linkTweet thisAlerts:
@sparkoframMar 11.2011 — Hello, dear i have tried for multiple upload as mention u above but only one image upload at the same time. what's the problem i could not find it.

move_uploaded_file(

$_FILES["pictures"]["tmp_name"][$key],

$_
FILES["pictures"]["name"][$key]

) or die("Problems with upload");
Copy linkTweet thisAlerts:
@stoneman30Mar 14.2011 — [code=php]<?php
$uploads_dir = '/uploads';
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, "$uploads_dir/$name");
}
}
?>
[/code]


This is a snippet directly from the PHP manual that shows how to upload multiple files. You can find it at http://us.php.net/manual/en/function.move-uploaded-file.php.

I also meant to mention that you should ensure that you have the ability to upload files on the server you are on and that you have your php.ini file setup properly to allow uploads.
Copy linkTweet thisAlerts:
@stoneman30Mar 14.2011 — One more thing. You may have an issue with your files being too big. Check out http://www.radinks.com/upload/config.php if you are having issues with large image file sizes. It shows you how to configure the php.ini file so that it can handle larger uploads.
×

Success!

Help @shutterbug 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 4.30,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...