【发布时间】:2016-09-28 23:54:06
【问题描述】:
应用程序的文件上传/下载部分受密码保护,因此只有管理员可以上传、查看和下载文件。但它们不能驻留在 public_html 中,因为它们包含个人信息,并且必须在未登录的情况下访问。
我可以更改上传文件夹 - 但它似乎必须在 public_html 内,否则您无法查看上传的内容,也无法下载它们。
这适用于 web public_html 目录中的“正常”操作——但是如何将 'upload_url' => HTTP_SERVER 设置为 public_html 之外?似乎必须进行一些路径转换,以便 file_upload 应用程序可以提供下载链接,也许是用户浏览器的缓冲读取输出?
<?php
// index.php
/*
* jQuery File Upload Plugin PHP Example
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2010, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
// using jQuery-File-Upload version: 9.12.5
error_reporting(E_ALL | E_STRICT);
// UploadHandler.php and index.php remain in the default location
// jQuery-File-Upload_root/server/php/
require('UploadHandler.php');
define('DIR_DOWNLOAD', '../../_uploads/'); // the directory is in jQuery-File-Upload_root/_uploads
define('HTTP_SERVER', 'http://localhost/jQuery-File-Upload-9.12.5/_uploads/');
$upload_handler = new UploadHandler(
array(
'upload_dir' => DIR_DOWNLOAD,
'upload_url' => HTTP_SERVER,
)
);
【问题讨论】: