Plupload filename problem

僤鯓⒐⒋嵵緔 提交于 2019-12-11 04:07:21

问题


I ask here in the hope that some members will be familiar enough with 'plupload' to help. This little Jquery script is on the way to making my file-upload problems go away, so any help would be greatly appreciated.

Question: I can upload large files using plupload, but when the appear on the server the name has changed to gibberish,

EG p163g1k1er15n310bi18bq1af61rc21.zip

From my experience with basic upload forms my assumption is that it is writing out a temp filename with the intention of renaming it to the original filename when the chunked sections have been put back together, but for some reason it may not be doing this.

I have changed the permission on the folder to 777, so I'm reasonably sure this isn't the issue.

The runtime being used is Flash (I require the chunking feature). It's version 1.4.3.2

As always, any help would be much appreciated.


回答1:


There is a configuration option to generate unique file names instead of using the actual file name.

From the docs:

unique_names Generate unique filenames when uploading. This will generate unqiue filenames for the files so that they don't for example collide with existing ones on the server.

Make sure this option is not enabled in your configuration (it is not by default). There are still some file name cleaning routines run by the default included php upload script...

// Clean the fileName for security reasons
$fileName = preg_replace('/[^\w\._]+/', '', $fileName);

...and an underscore is always appended with a number if the file exists (regardless of configuration), like filename_2.jpg, but aside from that it should not be altering your file names.

EDIT: I've been searching the forums for a solution but coming up short, my last piece of advice is to try the HTML5 runtime, to see if this is related to the Flash runtime somehow, as there have been some issues with previous versions. If all else fails, post on the forum - the admins there are very responsive. Best of luck, please post a solution here if you find it.




回答2:


Ploploader uses a variable called "unique_names"; in my case this was set to TRUE, however to preserve the actual filenames it should be set to false. Solution came from the Pluploader forum.




回答3:


To keep original filename, if you use the upload.php provided by plupload then I had to change upload.php line 34 from

$fileName = isset($_REQUEST['name']) ? $_REQUEST['name'] : '';

to

$fileName = isset($_FILES['file']["name"]) ? $_FILES['file']["name"] : '';



回答4:


I had the same problem. An another solution is to inject real file name as a new input into FormData object. (I am using chrome and HTML5 runtime!) in plupload.html5.js file find the creation of object O = new FormData(); and add some injections with

var oFileName = $("input[name='oFileName']").val();
O.append("oFileName", V.name);

After this adding get the real file name in your server side (for upload.php)

$oFileName = $_REQUEST["oFileName"];


来源:https://stackoverflow.com/questions/6534734/plupload-filename-problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!