laravel 使用 jquery 的最简单的拖放文件上传插件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13147736/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Easiest drag and drop files uploader plugin using jquery
提问by Pigalev Pavel
I've faced a problem... I can not find a good and easy to understand plugin that can upload files to server by clicking and choosing a file or just by draging and droping a file to some area... I know that there are a lot of plugins in web but I couldn't really make most of them work at my server...
我遇到了一个问题......我找不到一个好的且易于理解的插件,它可以通过单击并选择文件或仅通过将文件拖放到某个区域来将文件上传到服务器......我知道有网络中有很多插件,但我无法真正让它们中的大部分在我的服务器上工作......
For example, http://fineuploader.comis good but it uses GET request as I understood which is not very good for me and anyway it didn't work... in controller url which was written in 'action' property in js I wrote a script just to understand if something is uploading or not, the console showed that $_FILES array was empty... and 'upload failed' was written in the drag and drop box...I don't know why and what was the problem...
例如,http://fineuploader.com很好,但据我所知它使用 GET 请求,这对我来说不是很好,无论如何它不起作用......我写了一个脚本只是为了了解是否正在上传某些内容,控制台显示 $_FILES 数组为空...并且在拖放框中写入了“上传失败”...我不知道为什么以及什么是问题吗...
For those of you who understood what I was talking about:
对于那些理解我在说什么的人:
I am using Laravel Framework...
我正在使用 Laravel 框架...
This is what I wrote in js properties:
这是我在js属性中写的:
action:'<?=URL::to_action('test@upload')?>'
This is how my controller looks like:
这是我的控制器的样子:
<?php
class Test_Controller extends Base_Controller {
public $restful = true;
public function post_upload() {
$input = Input::All();
print_r($input);
print_r($_FILES);
if (isset($_GET['file'])) {
echo "good ";
} else {
echo "bad ";
}
}
}
?>
And when I was trying to uploade a file console showed me $input array that contained something like this Array ([file] => 'image.png')
and a $_FILES array that was empty Array()
... And my last check was returning "good"... If you know how to handle this problem please help!
当我尝试上传文件时,控制台向我显示了包含类似内容的 $input 数组Array ([file] => 'image.png')
和一个空的 $_FILES 数组Array()
......而我的最后一次检查返回“好”......如果你知道如何处理这个问题请帮忙!
Or maybe someone knows another good and easy drag and dropping files uploader plugin... I will be very grateful!!!
或者也许有人知道另一个好的和简单的拖放文件上传插件......我将不胜感激!!!
采纳答案by Pigalev Pavel
I've found the best drag and drop jquery plugin! It is simple to understand and simple to work with!
我找到了最好的拖放 jquery 插件!它易于理解且易于使用!
Here is the link: jquery-filedrop.
这是链接:jquery-filedrop。
回答by Harshal Lonare
I found easiest drag and drop plugin available online: http://www.dropzonejs.com/
我在网上找到了最简单的拖放插件:http: //www.dropzonejs.com/
with jQuery have a look
用jQuery看看