Переименуйте файл перед загрузкой с помощью кода plupload.Uploader и удалите файл из очереди, не работает.Php

Кемеровские программисты php общаются здесь
Ответить Пред. темаСлед. тема
Anonymous
 Переименуйте файл перед загрузкой с помощью кода plupload.Uploader и удалите файл из очереди, не работает.

Сообщение Anonymous »


I have two problems.
First of all the remove a file from queue is not working well. When I use remove link of the chosen file from queue, the link refresh the whole page. For example when I chose two files and I want to remove one of them with the remove link, with refreshing the page I lose both file in the queue. Do you have any suggestion what do I have to do differently?
Second problem:

I have an index with Java code from plupload.Uploader and a 2b-chunk.php as an upload file witch that code aloud me to upload large files and it works perfect.

But, I need to have the option rename the selected file before uploading it. So, I wrote an input code with ol to give the name as I wish there before I use the send button but I do not know what is the method sending it to 2b-chunk.php code for caching the new file name implanting to the code. Do you think my though is correct for my goal and what do I miss? If my code is correct what code do I have to change in my 2b-chunk.php to keep the chunk option with the new name of my file?
My plupload index code:

Код: Выделить всё

Plupload - Custom example






#info_div_center {
width:250px;
height:auto;
text-align: center;
margin-top: -12px;
}
ol.phpfmg_form{
list-style-type:none;
padding:2px 2px 2px 2px;
font-family: 'Glyphicons Halflings', "Times New Roman", "serif";
font-size: 12px;
position: static;
resize: vertical;
width: 50%;
}
ol.phpfmg_form input{
border: 1px solid #CCC;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 8px;
padding:3px 3px 3px 3px;
font-size: 12px;

}
.phpfmg_form input:hover {
background:#E8E8E8;
}
input:focus::placeholder {
color: transparent;
}





Custom example

Shows you how to use the core plupload API.

Your browser doesn't have HTML5 support.


Select files
Upload





// Custom example logic

var uploader = new plupload.Uploader({
runtimes: 'html5,flash,silverlight,html4',
browse_button: 'pickfiles', // you can pass an id...
container: document.getElementById('container'), // ...  or DOM Element itself
//max_retries: 1,
//multipart: false,
chunk_size: '1mb',
//multiple_queues: false,
//unique_names: true,
url: "2b-chunk.php",

filters: {
max_file_size: '1000mb',
mime_types: [
{ title: "Image files", extensions: "jpg,jpeg,gif,png" },
{ title: "Zip files", extensions: "zip" },
{ title: "Movie files", extensions: "mov,mp4" },
{ title: "Audio files", extensions: "mp3,wav" },
{ title: "Documents files", extensions: "pdf,doc,docx" }
]
},
flash_swf_url: 'js/Moxie.swf',    // Flash settings
silverlight_xap_url: 'js/Moxie.xap',    // Silverlight settings

init: {

PostInit: function() {
document.getElementById('filelist').innerHTML = '';
document.getElementById('uploadfiles').onclick = function() {
if (uploader.files.length < 1) {
document.getElementById('console').innerHTML = 'Please select a file to upload.
';
setTimeout(function () {
window.location.reload();
}, 2000)
return false;
}else{
uploader.start();
return false;
}
};
},

FilesAdded: function(up, files) {
plupload.each(files, function(file) {
document.getElementById('filelist').innerHTML += '' + file.name + ' (' + plupload.formatSize(file.size) + ') [/b] '+'Remove'+'[list][/list]'+'';

});
},
BeforeUpload: function(up, file) {
uploader.settings.multipart_params = { 'renamedFileName': 'yourRenamedFileName' };
});

UploadProgress: function(up, file) {
document.getElementById(file.id).getElementsByTagName('b')[0].innerHTML = '' + file.percent + "%";
},

FileUploaded: function(up, file, result) {
var responseData = result.response.replace('"{', '{').replace('}"', '}');
var objResponse = JSON.parse(responseData);
document.getElementById('console').innerHTML = '
' + objResponse.result.message + '
';
},
UploadComplete(up, file) {
setTimeout(() => {
window.location.reload();
}, 3000);
},

Error: function(up, err) {
document.getElementById('console').appendChild(document.createTextNode("\nError #" + err.code + ": " + err.message));
setTimeout(function () {
window.location.reload();
}, 2000)
return false;
}
},
});
uploader.init();


My 2b-chunk.php code

Код: Выделить всё


Источник: [url]https://stackoverflow.com/questions/78132258/rename-a-file-before-uploading-using-plupload-uploader-code-and-remove-file-from[/url]
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение
  • Переименуйте файл перед загрузкой с помощью кода plupload.Uploader и удалите файл из очереди, не работает.
    Гость » » в форуме Php
    0 Ответы
    61 Просмотры
    Последнее сообщение Гость
  • PLUPLOAD PHP Большой размер загрузки видео
    Anonymous » » в форуме Php
    0 Ответы
    4 Просмотры
    Последнее сообщение Anonymous
  • Fine-Uploader PHP Server Side Merge
    Anonymous » » в форуме Php
    0 Ответы
    54 Просмотры
    Последнее сообщение Anonymous
  • Fine-Uploader PHP Server Side Merge
    Anonymous » » в форуме Jquery
    0 Ответы
    47 Просмотры
    Последнее сообщение Anonymous
  • Использование Syncfusion-Vue-Uploader с VUE-3
    Anonymous » » в форуме Javascript
    0 Ответы
    12 Просмотры
    Последнее сообщение Anonymous

Вернуться в «Php»