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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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