jQuery Blueimp上载插件的自定义$ options目录? [英] Custom $options directory for jQuery Blueimp Upload Plugin?

查看:52
本文介绍了jQuery Blueimp上载插件的自定义$ options目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用 blueimp jQuery File Upload插件,尝试设置自定义字段时,用户可以更改其上载内容.

I have been working with the blueimp jQuery File Upload plugin and I'm trying to setup a custom field the user can change for uploads.

在PHP类中,有一个可设置所有默认选项变量的构造.我正在寻找存储这些数据的最佳方法,因此在用户设置值后,它将保存为新的默认上传文件夹.我正在考虑在一个外部XML文件中,将其导入到PHP脚本中.

Within the PHP class there is a construct which sets up all the default options variables. I'm looking for the best way I can store this data so after the user sets a value it'll save as the new default upload folder. I'm thinking inside an external XML file, which is them imported into the PHP script.

这是上载类的构造函数:

Here's the upload class constructor function:

    function __construct($options=null) {
    $this->options = array(
        'script_url' => $this->getFullUrl().'/',
        'upload_dir' => dirname($_SERVER['SCRIPT_FILENAME']).'/files/',

我希望这是有道理的,我很乐意澄清任何事情.但基本上-我如何允许用户手动输入目录结构,该目录结构成为图像的新上传目录?我在哪里可以保存这个新的字符串变量?可能不在PHP内,但可能在XML或JSON之类的外部文件中?

I hope this makes sense and I'm happy to clarify anything. But basically - how can I allow users to manually enter a directory structure and that becomes the new upload directory for images? Where could I save this new string variable? Probably not inside PHP but possibly in an external file, like XML or JSON?

推荐答案

我注意到您,并且大约在同一时间在github上发布了blueimp上传问题.我不确定我是否能为您提供完整的答案,但是请允许我提供到目前为止所找到的信息.也许会有所帮助:

I noticed you and I posted a blueimp upload issue on github at about the same time. I'm not sure I have a complete answer for you, but let me give you what I've found so far. Maybe it will help:

我一直在寻找一种方法,可以在经过身份验证的系统中按用户过滤上传的文件.我发布了github.com/blueimp/jQuery-File-Upload/issues/1578.插件作者建议我在服务器端进行过滤.我找到了github.com/blueimp/jQuery-File-Upload/issues/1149,其中说明了如何在服务器端进行过滤.我已经做到了,并且可以上传.现在,我进行了设置,其中每个用户在上载文件夹中都有一个子文件夹,名为其唯一ID号,其中包含其图像.因此,无论如何,这是一种设置上传路径的动态方式.也许您可以使用它.

I have been looking for a way to filter uploaded files by user from within an authenticated system. I posted github.com/blueimp/jQuery-File-Upload/issues/1578 . The plugin author suggested that I filter on the server side. I found github.com/blueimp/jQuery-File-Upload/issues/1149 which explains how to filter on the server side. I've done this and it works as far as uploading. I now have it setup where each user has a subfolder in the upload folder named their unique ID number which contains their images. So anyway, this is a dynamic way to set the upload path. Maybe you can use it.

我当前的问题是,尽管我可以确认已上传图像,但它们在下载表中不可见.请参阅github.com/blueimp/jQuery-File-Upload/issues/1587.

My current problem is that although I can confirm that the images are uploaded they are not visible in the download table. Please see github.com/blueimp/jQuery-File-Upload/issues/1587 .

我已尝试解决此问题,包括尝试将选项传递给构造函数:

One attempt I've made to fix this included trying to pass options into the constructor:

这是我在blueimp index.php文件中的代码:

Here is my code in the blueimp index.php file:

$customer_path_files = dirname($_SERVER['SCRIPT_FILENAME']) .     DIRECTORY_SEPARATOR.         'files' . DIRECTORY_SEPARATOR . $uid . DIRECTORY_SEPARATOR;
    if (!file_exists($customer_path_files)) {
    @mkdir($customer_path_files);
}
$customer_path_thumbnails = dirname($_SERVER['SCRIPT_FILENAME']) . DIRECTORY_SEPARATOR     . 'thumbnails' . DIRECTORY_SEPARATOR . $uid . DIRECTORY_SEPARATOR;
if (!file_exists($customer_path_thumbnails)) {
    @mkdir($customer_path_thumbnails);
}

$options=array(
'upload_dir' => $customer_path_files,
'upload_url' => base_url().'blueimp/server/php/files/'.$uid.'/',
'thumbnail' => array(
                'upload_dir' => $customer_path_thumbnails,
                'upload_url' => base_url().'blueimp/server/php/thumbnails/'.$uid.'/',
                'max_width' => 80,
                'max_height' => 80
            )
);


require('upload.class.php');

$upload_handler = new uploadHandler($options);

希望这里有帮助,

附录:

希望如此.顺便说一句,我读了 Jquery File Upload插件:动态更改上传路径吗?.这正是我想要做的恰好.如果您也是,我只想说我也试图将隐藏字段中的会话变量(在我的情况下为codeigniter变体($ this-> session-> userdata('uid'))传递给插件的索引.php文件,但就像在帖子中一样,它在index.php中不存在(我认为是因为,未按下上载按钮以进行重新填充或删除).这是我对ajax的初次体验,但是我认为会话ID必须以某种方式通过Json发送.我试图弄清楚.这听起来像是Chris G所做的.如果有帮助,我已经发布了以下问题,并提供了更多详细信息:

I hope it does. BTW I read Jquery File Upload plugin: Dynamically change upload path?. That is exactly what I am trying to do. In case you are too, let me just say that I also tried to pass the session variable ( in my case the codeigniter variant ( $this->session->userdata('uid') ) in a hidden field to the plugin's index.php file, but just like in the post , it doesn't exist in index.php ( I think because , the upload button is not pushed for the repopulation or delete ). This is my first experience with ajax, but I think that the session ID must somehow be sent via Json. I'm trying to figure that out. It sounds like That's what Chris G did. If its any help I've posted the following question with some more details:

http://www.dynamicdrive.com/forums/showthread.php?p = 279824

这篇关于jQuery Blueimp上载插件的自定义$ options目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆