0
嗨,我是jquery的新手。我想要重命名upload..but文件我不能這樣做如何在jquery文件上傳中重命名文件
我使用文件中的代碼上傳
$(function() {
var btnUpload=$('#upload');
var status=$('#status');
new AjaxUpload(btnUpload, {
action: 'upload-file.php',
name: 'uploadfile',
onSubmit: function(finalname, ext){
if (! (ext && /^(pdf|doc|docx|xls|xlsx|text|)$/.test(ext))){
status.text('Only pdf, xls,doc,docs,xlsx and text files are allowed');
return false;
}
status.text('Uploading...');
},
onComplete: function(finalname, response){
status.text('');
if(response==="success"){
$('#head').val(finalname);
} else{
status.text('Upload Failed');
}
}
});
PHP代碼是
$uploaddir = 'uploads/files/';
$file = $uploaddir . basename($_FILES['uploadfile']['name']);
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) {
echo "success";
} else {
echo "error";
}
的Html
<div id="upload" ><span>Browse<span></div><span id="status" ></span>
<input type="text" id="head" name="head" value="">
我能夠用PHP文件重命名......但不是在jQuery代碼它給我錯誤的文件名好心幫
人們來這裏不是爲了幫助 – RItika