'Plupload unable to upload files over 940kb, this is the issue with larger files

When uploading files with pluploader the small files are uploaded without issue, but as soon as the files are chunked the script loses the actual file name which results in the following error:

Failed to open input stream

So, I need a way to pass the actual filename from the HTML form to the upload php. There is a line in the custom.html file that says:

browse_button : 'pickfiles', // you can pass an id...
container: document.getElementById('container'), // ... or DOM Element itself 

In the DOM the element I need is file.name in this script part

FilesAdded: function(up, files) {
    plupload.each(files, function(file) {
        document.getElementById('filelist').innerHTML += '<div id="' + file.id + 
        '">' + file.name + ' (' + plupload.formatSize(file.size) + ') <b></b></div>';
    });

Can anyone suggest how I can achieve this? I have tried accessing the element with java and isset but without any success.



Solution 1:[1]

In plupload there is a main upload script called upload.php and this is the code that renames the uploaded file to a meaningless code i. e. file_6272e003ad256 and this is the code in upload.php that renames that file id name

// Check if file has been uploaded
if (!$chunks || $chunk == $chunks - 1) {
    // Strip the temp .part suffix off 
    rename("{$filePath}.part", $filePath);

So, search this file for the word filename

    // What to look for
$search = 'filename';
// Read from file
$lines = file('file_6272e003ad256');
foreach($lines as $line)
{
  // Check if the line contains the string we're looking for, and print if it does
  if(strpos($line, $search) !== false)
    echo $line;
}

Then extract the phrase between the double quotes and this is the filename to rename the file with

rename($filePath, $original_filename);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mark.four