Question

I've googled and googled but can't seem to find a way to have a multiple file upload then crop/resize each image. I'm using image magician for my single file uploads and it works great!

Any help would be greatly appreciated!

p.s this is in PHP

Was it helpful?

Solution

Handling multiple files shouldn't be that different than handling a single one.

Assuming the following HTML:

<form method="post" enctype="multipart/form-data" action='upload.php'>
    <p>Files: <input name="images[]" multiple="multiple" type="file" /></p>
    <input type="submit" value="Upload" />
</form>

Your PHP might look as follows:

foreach($_FILES['images']['tmp_name'] as $key => $tmp_name) {
    $fileName = $_FILES['images']['name'][$key];
    $fileSize = $_FILES['images']['size'][$key];
    $fileTmp = $_FILES['images']['tmp_name'][$key];
    $fileType = $_FILES['images']['type'][$key];
    ...
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top