Topic: Calling separate PHP library after FileUploaded

I'm fairly new to PHP so hopefully this turns out to be trivial. I have Plupload running on my server using the example implementation and everything works smoothly. However, after a file is finished uploading, I'd like to pass the $fileName variable to a separate PHP library which will upload them to a separate server. What I have right now is the example jQuery queue widget sending files to the example upload.php, with this tacked on to the end of it:

include 'phplibrary.php';
    try {
        // Plupload $targetDir is imgcache/
        $f->images_upload("File=imgcache/".$fileName);
    }
    catch ( Exception $e ) {
    echo "{$e->getMessage()} (Error Code: {$e->getCode()})";
    }

But instead of passing the file to the library once all the chunks have been uploaded, this passes the file each time a new chunk has been completed. So I end up with multiple successive fragments on the second server whenever the file is bigger than the chunk size. Looking through the API, it seems like the FileUploaded event would be useful in correcting this, but I can't figure out how to implement it with uploader.bind or within upload.php

If anyone has an idea I'd appreciate it.

2 (edited by mike 2011-04-10 20:08:00)

Re: Calling separate PHP library after FileUploaded

Do you need chunks?  If you don't use chunks the file will appear as one piece on the server which might be a bit easier to handle.

Regardless you need to handle the uploaded file on your server (whether it comes in in chunks or one piece).  Deal with it in upload.php - or whatever you write to handle the incoming POSTs from the web browser on your server.

Re: Calling separate PHP library after FileUploaded

Without chunking, large files fail to complete within the maximum execution time I can have on my host.

So how do I handle FileUploaded in upload.php? I've seen the examples on using upload.bind('FileUploaded', function(etc...)) in javascript, but I can't figure out how to implement it in PHP.

Re: Calling separate PHP library after FileUploaded

You can't use FileUploaded in PHP, check this thread for a way to detect file uploaded situation on server. On the other side, you probably could use FileUploaded in javascript and let the server know that file was uploaded by ajax call.

If you want to see your issue fixed, do not report it here, do it on - GitHub.