jQuery的文件上传 [英] jQuery-File-Upload
问题描述
我想通过一个值来创建我的上传文件夹的名称。
基本上,在include中执行一个查询,一个数值被返回给变量$ leaseId_file。 - $ leaseId_file变量成为文件夹名称。
这部分工作正常。该文件夹被创建并且文件被保存到该目录。
但是,当我刷新页面时,上传的文件没有被列出。
以下是我在php / .index.php文件中使用的代码
- 任何帮助都会很棒.-谢谢。
error_reporting(E_ALL | E_STRICT);
include_once('../../../_ includes / get_leaseId_files.php'); //所有这些都会为$ leaseId_file返回一个值。这是我想要的目录的价值。
require('upload.class.php');
class CustomUploadHandler extends UploadHandler {
protected function get_user_id(){
global $ leaseId_file;
return $ leaseId_file;
$ upload_handler = new CustomUploadHandler(array(
'user_dirs'=> true
) );
你首先看看你立即可用的各种文件上传插件。如果你想要推出自己的解决方案,我保证你会遇到很多这样的问题。我认为,因为你使用jQuery已经让你的生活更轻松,为什么不把相同的逻辑应用到你的文件上传脚本?
这里有一些我会建议检查你是否不相信(没有特定的顺序):
- jQuery File Upload =nofollow> Uploadify
- - Not特别是jQuery,但支持HTML5和许多后备
- 不是插件,而是一个很好的教程
Not sure if you guys can assist this relates to the jQuery-File-Upload code. I am trying to pass through a value to create a folder name for my uploads. Basically a query is executed in the include and a numeric value is returned to the variable $leaseId_file . -The $leaseId_file variable becomes the folder name. This part works fine. The folder is created and files are saved to the directory. However, the uploaded files are not being listed when I refresh the page. The following is the code I used in the file php/.index.php - any help would be awesome.- Thanks.
error_reporting(E_ALL | E_STRICT);
include_once('../../../_includes/get_leaseId_files.php'); // All this does is returns a value for $leaseId_file. This is the value I want for the directory.
require('upload.class.php');
class CustomUploadHandler extends UploadHandler {
protected function get_user_id() {
global $leaseId_file;
return $leaseId_file;
}
}
$upload_handler = new CustomUploadHandler(array(
'user_dirs' => true
));
Since you're using jQuery, I'd suggest you first take a look at the various file upload plugins immediately available to you. If you're trying to roll your own solution, I guarantee you're going to hit a lot of problems like this. I figure though, since you're using jQuery to already make your life easier, why not apply the same logic to your file uploading script?
Here's a few I would suggest checking out if you're not convinced (in no particular order):
- jQuery File Upload
- Uploadify
- Plupload - Not jQuery specifically, but support for HTML5 and a number of fallbacks
- Not a plugin, but a good tutorial
这篇关于jQuery的文件上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!