The file upload / download part of the application is password-protected, so only the admin can upload, view and download the files. But they must not reside inside public_html because they contain personal information and must not be accessible without being logged in.
I am able to change the upload folder -- but it appears it must be inside of public_html else you can't view your uploads and you can't download them.
This works for "normal" operation inside the web public_html directory -- but how to set 'upload_url' => HTTP_SERVER to be outside public_html? Seems there would have to be some path translation so the file_upload app can provide a download link, perhaps a buffered read output the user's browser?
<?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,
)
);
If you want to save your files outside from your www
folder, then your files are not directly accessible through a url. In this case you do not need to provide any value for 'upload_url'
. Instead set 'download_via_php'
to true.
$options = array(
"upload_dir" => '/home/farawayfromwww/test/',
"download_via_php" => 1
);
error_reporting(E_ALL | E_STRICT);
require('UploadHandler.php');
$upload_handler = new UploadHandler($options);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.