Pergunta

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

Foi útil?

Solução

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];
    ...
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top