简体   繁体   中英

want to get the file name and its path which was uploaded using jquery plugin

I used a jquery plugin to upload a files into a specified folder.upload was done properly,What i want is to get the the name of the file and its path to store it in a database.I don,t know which variable i have to use get that .Here is my plugin,

$(function () {

    // Change this to the location of your server-side upload handler:
    var url = 'test_upload_charity.php';
    $('#fileupload').fileupload({
        url: url,
        dataType: 'json',
        done: function (e, data) {
            $.each(data.result.files, function (index, file) {
                $('<p/>').text(file.name).appendTo('#files');
            });
        },
        progressall: function (e, data) {
            var progress = parseInt(data.loaded / data.total * 100, 10);
            $('#progress .progress-bar').css(
                'width',
                progress + '%'
            );
        }
    }).prop('disabled', !$.support.fileInput)
        .parent().addClass($.support.fileInput ? undefined : 'disabled');
}); 

And my test_upload_charity.php is

<?php
error_reporting(E_ALL | E_STRICT);
include "UploadHandler_charity.php";
$uploadhandlerobj=new UploadHandler_charity();

$filename_uploaded=$uploadhandlerobj->get_file_name();

$file = fopen("test123456.txt","w");
echo fwrite($file,"The file is ".$filename_uploaded);
fclose($file);



?>

The UploadHandler_charity.php is

https://github.com/blueimp/jQuery-File-Upload

In that link it was inside server folder

Try to use:

$_FILES["file"]["name"]

I cannot find an official function in your library to get it.

If that does not work you can try printing the whole _FILES array:

print_r($_FILES); 

and see if you can find the needed data in the array.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM