简体   繁体   English

jQuery的文件上传

[英]jQuery-File-Upload

Not sure if you guys can assist this relates to the jQuery-File-Upload code. 不确定你们是否可以协助完成这与jQuery-File-Upload代码有关。 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 . 基本上,在include中执行查询,并将数值返回到变量$ leaseId_file。 -The $leaseId_file variable becomes the folder name. -$ leaseId_file变量成为文件夹名称。 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. 以下是我在文件php / .index.php中使用的代码-任何帮助都会很棒。-谢谢。

            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. 由于您使用的是jQuery,因此建议您首先查看立即可使用的各种文件上传插件。 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? 不过我认为,由于您使用的是jQuery,已经使您的生活更加轻松,为什么不对您的文件上传脚本应用相同的逻辑呢?

Here's a few I would suggest checking out if you're not convinced (in no particular order): 如果您不确信(不分先后顺序),以下是一些建议您使用的建议:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM