Gargron / fileupload

PHP FileUpload library that supports chunked uploads
MIT License
459 stars 87 forks source link

file name of upload completed #61

Closed blsn closed 6 years ago

blsn commented 7 years ago

59

list($files, $headers) = $fileupload->processAll();
echo json_encode(['files' => $files]);

Two files were uploaded. file name visible only for validation file error:

{"files":[{"error":"Filetype not allowed","errorCode":0,"completed":false,"name":"header-image.jpg","size":72193},{"error":0,"errorCode":0,"completed":true,"size":2254}]}

This will work only as follows:

        foreach($files as $file) {
            if ($file->completed) { // check if the upload was completed
                echo $file->getFilename();
            }
        }       

But how can I get the file names for both completed/uncompleted?

adelowo commented 7 years ago

@blsn Oh, I get that, I still get the file name for uncompleted uploads but it is the name as stored in the temporary directory (by PHP), something like PHPjks . The generated name (by the library) only works for completed files. Is there any reason you are trying to get the filename for uncompleted uploads ?

Pls let me know your reasoning. I would take a look at this tomorrow

blsn commented 7 years ago

To provide the user with a notification about the uncompleted file name beside the error message accordingly.

This feature is very important.