1
好吧,在这里有点厚 - 我认为,我正在看pangratz/dnd-file-upload和拖动&下降是伟大的等(我不知道跨浏览器等,但无所谓),但什么我不能做的是创建正确的PHP代码来处理实际的上传。HTML 5文件拖放文件上传通过php
这是基础的js代码
$(document).ready(function(){
$.fn.dropzone.uploadStarted = function(fileIndex, file){
var infoDiv = $("<div></div>");
infoDiv.attr("id", "dropzone-info" + fileIndex);
infoDiv.html("upload started: " + file.fileName);
var progressDiv = $("<div></div>");
progressDiv.css({
'background-color': 'orange',
'height': '20px',
'width': '0%'
});
progressDiv.attr("id", "dropzone-speed" + fileIndex);
var fileDiv = $("<div></div>");
fileDiv.addClass("dropzone-info");
fileDiv.css({
'border' : 'thin solid black',
'margin' : '5px'
});
fileDiv.append(infoDiv);
fileDiv.append(progressDiv);
$("#dropzone-info").after(fileDiv);
};
$.fn.dropzone.uploadFinished = function(fileIndex, file, duration){
$("#dropzone-info" + fileIndex).html("upload finished: " + file.fileName + " ("+getReadableFileSizeString(file.fileSize)+") in " + (getReadableDurationString(duration)));
$("#dropzone-speed" + fileIndex).css({
'width': '100%',
'background-color': 'green'
});
};
$.fn.dropzone.fileUploadProgressUpdated = function(fileIndex, file, newProgress){
$("#dropzone-speed" + fileIndex).css("width", newProgress + "%");
};
$.fn.dropzone.fileUploadSpeedUpdated = function(fileIndex, file, KBperSecond){
var dive = $("#dropzone-speed" + fileIndex);
dive.html(getReadableSpeedString(KBperSecond));
};
$.fn.dropzone.newFilesDropped = function(){
$(".dropzone-info").remove();
};
$("#dropzone").dropzone({
url : "upload.php",
printLogs : true,
uploadRateRefreshTime : 500,
numConcurrentUploads : 2
});
});
但我不能让upload.php的以任何方式
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = '';
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
move_uploaded_file($tempFile,$targetFile);
echo str_replace($_SERVER['DOCUMENT_ROOT'],'',$targetFile);
建议等欢迎我需要做的工作是上传图像化,以服务器和理智的数据库(保存不坏,一次我可以得到拖动&下降的图像移动到服务器哦,我不想使用第三方应用程序
谢谢提前
我没有得到任何错误'因为upload.php脚本不起作用;) –
Aggg我想我意外地从Damien删除了一条评论 - 对不起 –
任何错误信息?检查了你的js console/php错误日志?如果你需要帮助,“不工作”并不是很有用。 –