jQuery 文件上传器插件和 Symfony 2
jQuery File Uploader Plugin and Symfony 2
我想在我的 symfony 2 项目中使用这个插件:
https://github.com/blueimp/jQuery-File-Upload/wiki/Basic-plugin
我遵循了文档中的所有步骤。但它一直说找不到这条路径:
error:
Failed to load resource: the server responded with a status of 404 (Not Found)
path:
http://localhost/vdvinfra/web/js/file-uploader/server/php/
我在 twig 文件中的代码:
<input id="fileupload" type="file" name="files[]" data-url="{{asset('js/file-uploader/server/php/')}}" multiple>
我的 js :
<script type="text/javascript">
$(function () {
$('#fileupload').fileupload({
/* ... */
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .bar').css(
'width',
progress + '%'
);
}
});
});
</script>
我认为 web/
不应该是您路径的一部分(除非 http://localhost/vdvinfra/web/
是您应用程序的基本路径)。你能打印 {{asset('js/file-uploader/server/php/')}}
的输出吗?
此外,当您希望 Symfony 处理您的上传时,我建议您查看 OneupUploaderBundle bundle. It has step by step 有关如何使用 jQuery 文件上传器插件设置 Symfony 的说明。
我想在我的 symfony 2 项目中使用这个插件:
https://github.com/blueimp/jQuery-File-Upload/wiki/Basic-plugin
我遵循了文档中的所有步骤。但它一直说找不到这条路径:
error:
Failed to load resource: the server responded with a status of 404 (Not Found)
path:
http://localhost/vdvinfra/web/js/file-uploader/server/php/
我在 twig 文件中的代码:
<input id="fileupload" type="file" name="files[]" data-url="{{asset('js/file-uploader/server/php/')}}" multiple>
我的 js :
<script type="text/javascript">
$(function () {
$('#fileupload').fileupload({
/* ... */
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .bar').css(
'width',
progress + '%'
);
}
});
});
</script>
我认为 web/
不应该是您路径的一部分(除非 http://localhost/vdvinfra/web/
是您应用程序的基本路径)。你能打印 {{asset('js/file-uploader/server/php/')}}
的输出吗?
此外,当您希望 Symfony 处理您的上传时,我建议您查看 OneupUploaderBundle bundle. It has step by step 有关如何使用 jQuery 文件上传器插件设置 Symfony 的说明。