[英]HTMLDOM: How to change text “files selected” from upload button using jquery or javascript?
[英]Plupload unable to upload files over 940kb, this is the issue with larger files
使用 pluploader 上傳文件時,小文件可以毫無問題地上傳,但是一旦文件被分塊,腳本就會丟失實際文件名,從而導致以下錯誤:
Failed to open input stream
所以,我需要一種方法將實際文件名從 HTML 表單傳遞到上傳custom.html
文件中有一行內容為:
browse_button : 'pickfiles', // you can pass an id...
container: document.getElementById('container'), // ... or DOM Element itself
在 DOM 中,我需要的元素是此腳本部分中的file.name
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>';
});
誰能建議我如何實現這一目標? 我嘗試使用 java 和 isset 訪問該元素,但沒有成功。
在 plupload 中有一個名為 upload.php 的主要上傳腳本,這是將上傳文件重命名為無意義代碼的代碼,即 file_6272e003ad256,這是 upload.php 中的代碼,重命名該文件 ID 名稱
// Check if file has been uploaded
if (!$chunks || $chunk == $chunks - 1) {
// Strip the temp .part suffix off
rename("{$filePath}.part", $filePath);
所以,在這個文件中搜索文件名這個詞
// 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;
}
然后提取雙引號之間的短語,這是要重命名文件的文件名
rename($filePath, $original_filename);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.