-2

I'm very interested getting the path and name of the file uploaded, and if the upload is a success, execute a php using the name and path of the uploaded file.

I just checked that on.complete could be useful, but if someone has an example would be just great.

.on('complete', function (event, id, filename, responseJSON) {
    uploadedFileCounter++;
    if (filesToUpload == uploadedFileCounter)
    {                


$(':input[type=button],:input[type=submit],:input[type=reset]').removeAttr('disabled');                                                
        //$("#overlay").fadeOut();
        $("#modal-box").fadeOut();
        $("#modal-overlay").fadeOut();               
    }

I found this example on another thread, but I don't have any idea how could I get the path and name on a php to store in a database and launch a new process with the uploded files.

sharkbait
  • 2,980
  • 16
  • 51
  • 89
  • Well, it looks like you already see how to get the name. Care you looking for the final path of the file on your server, or the original path of the file on the users machine? – Ray Nicholus Apr 18 '14 at 12:41

1 Answers1

0

So here is an example of how to do some of these tasks in plain ol' PHP. Would not recommend for production!

To get the filename in PHP:

function getName(){

    // First we check if the user has provided an edited version of the filename.
    // see: http://docs.fineuploader.com/branch/master/features/filename-edit.html
    if (isset($_REQUEST['qqfilename']))
        return $_REQUEST['qqfilename'];

    // Otherwise we return whatever the browser/fine-uploader has named the file.
    // see: http://docs.fineuploader.com/endpoint_handlers/traditional.html
    if (isset($_FILES[$this->inputName]))
        return $_FILES['qqfile']['name'];

}

To get the UUID in PHP:

// see: http://docs.fineuploader.com/endpoint_handlers/traditional.html
$uuid = $_REQUEST['qquuid'];

One method of creating a path on disk is to use the uuid in combination with the filename like so:

$path = join(DIRECTORY_SEPARATOR, array($uuid, get_name()));

At this point you can do whatever you want with the path, uuid, filename, or other data from fine-uploader (e.g., save the data in a database, ...)

If there is some reason fine-uploader needs to know the path, then you can return it in the response and use it in the onComplete handler:

.on('complete', function (event, id, filename, responseJSON) {
    var path = responseJSON.path;
    // do something ...
}
Mark Feltner
  • 2,041
  • 1
  • 12
  • 23