Jump to content

PHP Batch Upload


spacepoet

Recommended Posts

I am trying to create a simple batch upload to "attach" to client's sites so they can use that in order to send me photos.

 

I have been searching for a script and don't see one.

 

I did find this, but it has no FORM to use:

<?php

set_time_limit(0);  

$dir = "/path/to/the/uploaded/pictures/"; // trailing slash
$moveto = "/path/to/where/they/should/be/copied/"; // trailing slash

$files = glob($dir . "*.jp{e,}g"); // list of files, sorted by name
$i = 1; // numbering
foreach ($files as $filename) {
    $image = imagecreatefromjpeg($filename); if (!$image) continue; // load
    $w = imagesx($image); $h = imagesy($image); // width, height
    $neww = 140; $newh = $h * $neww / $w; // resized
    $thumb = imagecreatetruecolor($neww, $newh);
    imagecopyresampled($thumb, $image, 0, 0, 0, 0, $neww, $newh, $w, $h); // create thumbnail

    imagejpeg($image, $moveto . $i . ".jpg"); // copy original
    imagejpeg($thumb, $moveto . $i . "_th.jpg"); // copy thumbnail

    // optional:
    echo "copied ", basename($filename), " (orig: $w, $h) to $i (thumb: $neww, $newh)<br>\n";

    $i++;
    imagedestroy($image); imagedestroy($thumb);
}

?> 

 

???

 

Would I just need to add a TEXTAREA to it, and then people can drag-and-drop .JPGs into it and it will automatically upload the files?

 

I am not certain.

 

I would have thought there would be a free script for this, since it's so common.

Link to comment
https://forums.phpfreaks.com/topic/226504-php-batch-upload/
Share on other sites

that script is more set for allowing users to FTP upload and then allowing you to execute and copy them all across.

 

there are plenty of upload scripts around, a quick google pulled these 3 ajax/jquery scripts (drag & drop etc)

http://valums.com/ajax-upload/

http://www.uploadify.com/

http://plugins.jquery.com/project/file_uploader

 

and here is a single PHP image upload script

http://www.reconn.us/content/view/30/51/

Link to comment
https://forums.phpfreaks.com/topic/226504-php-batch-upload/#findComment-1169090
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.