如何通过dropzone返回上传的图像路径
How to get back uploaded image path by dropzone
我试图返回dropzone的成功函数,但它不起作用。我需要在图片上传页面上返回路径和图片名称。。。
我的代码:
<body>
<button id="submit-all">Submit all files</button>
<form action="uploads.php" class="dropzone" id="my-dropzone"></form>
<script>
Dropzone.options.myDropzone = {
// Prevents Dropzone from uploading dropped files immediately
addRemoveLinks: true,
autoProcessQueue: false,
maxFilesize:100,
parallelUploads:5,
maxFiles:5,
acceptedFiles: "image/*,.pdf, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.openxmlformats-officedocument.spreadsheetml.template, application/vnd.openxmlformats-officedocument.presentationml.template, application/vnd.openxmlformats-officedocument.presentationml.slideshow, application/vnd.openxmlformats-officedocument.presentationml.presentation, application/vnd.openxmlformats-officedocument.presentationml.slide, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.openxmlformats-officedocument.wordprocessingml.template, application/vnd.ms-excel.addin.macroEnabled.12, application/vnd.ms-excel.sheet.binary.macroEnabled.12,text/rtf,text/plain,audio/*,video/*,.csv,.doc,.xls,.ppt,application/vnd.ms-powerpoint,.pptx",
init: function() {
var submitButton = document.querySelector("#submit-all"),
myDropzone = this; // closure
submitButton.addEventListener("click", function() {
myDropzone.processQueue(); // Tell Dropzone to process all queued files
});
}
};
</script>
</body>
和上传脚本:
$upload_dir = 'uploads';
if (!empty($_FILES)) {
$tempFile = $_FILES['file']['tmp_name'];
echo $tempFile;
// using DIRECTORY_SEPARATOR constant is a good practice, it makes your code portable.
$targetPath = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . $upload_dir . DIRECTORY_SEPARATOR;
// Adding timestamp with image's name so that files with same name can be uploaded easily.
$mainFile = $targetPath.time().'-'. $_FILES['file']['name'];
move_uploaded_file($tempFile,$mainFile);
} else { echo 'error: no file'; }
我需要成功函数来返回上传图像的路径。谢谢
myDropzone.processQueue();
myDropzone.on("success", function(file,responsenew) {
// alert(responsenew);
var response = jQuery.parseJSON(responsenew);
$('#image_update').remove();
if(response.html==undefined || response.html==null) {
}
});
相关文章:
- 复制图像路径以单击它
- 如何使用jquery将base64图像路径转换为真实路径
- 滚动页面时的弯曲图像路径
- Gulp bower图像路径
- Symfony2-Javascript文件中的图像路径
- 将图像内容而非图像路径存储在mongodb中
- MVC5 和 Javascript 相对图像路径混淆
- 简单的图像滑块Javascript图像路径在IE 6中不起作用
- 从表单中派生要使用javascript对象加载的图像路径
- 如何设置与CKEditor一起使用的图像路径
- AngularJS/JavasScript中的本地图像路径
- 将 grunt-usemin 与动态生成的图像路径一起使用
- 如何使用 php 将捕获的图像路径存储在 mysql 数据库中
- 需要 Rails 应用程序中本机 HTML 的图像路径
- Javascript 无法解析正确的图像路径,当使用 URL 路由在 ASP.Net 中请求页面时
- 在 jquery 中为内联 css 构建图像路径的最佳方法
- “电子邮件”在电话间隙中共享的图像路径
- 使用带有错误图像路径的 jQuery 加载打开的页面
- 推送整个网站数组中的所有图像路径
- 使用一个javascript字符串作为css背景属性的图像路径