我正在使用jquery库blueimp上传。 我想将图像上传到不同的目录。 我刚刚修改了/ server / php / index.php 文件(只有这个文件):
error_reporting(E_ALL | E_STRICT);
require_once('UploadHandler.php');
//$upload_handler = new UploadHandler();
define(DIR_DOWNLOAD, "/Applications/XAMPP/htdocs/villalba2");
define(HTTP_SERVER, "localhost/villalba2");
$blogId= "Mobiliario";
$upload_handler = new UploadHandler(array(
'upload_dir' => DIR_DOWNLOAD . '/uploads/' . $blogId. '/',
'upload_url' => HTTP_SERVER . '/uploads/' . $blogId. '/',
));
权限文件夹是777
图像正确加载到我想要的目录中,但是我收到此错误:
Chrome - > SyntaxError:意外的令牌<
Safari - > SyntaxError:JSON解析错误:无法识别的标记'<'
/ server / php / index.php 的结果是:
<b>Notice</b>: Use of undefined constant DIR_DOWNLOAD - assumed 'DIR_DOWNLOAD' in <b>/Applications/XAMPP/xamppfiles/htdocs/villalba2/up/server/php/index.php</b> on line <b>16</b><br />
<br />
<b>Notice</b>: Use of undefined constant HTTP_SERVER - assumed 'HTTP_SERVER' in <b>/Applications/XAMPP/xamppfiles/htdocs/villalba2/up/server/php/index.php</b> on line <b>17</b><br />
{"files":[{"name":"cama (1).jpg","size":101775,"url":"localhost\/villalba2\/uploads\/Mobiliario\/cama%20%281%29.jpg","thumbnailUrl":"localhost\/villalba2\/uploads\/Mobiliario\/thumbnail\/cama%20%281%29.jpg","deleteUrl":"http:\/\/localhost\/villalba2\/up\/server\/php\/?file=cama%20%281%29.jpg","deleteType":"DELETE"},{"name":"cama (2).jpg","size":101775,"url":"localhost\/villalba2\/uploads\/Mobiliario\/cama%20%282%29.jpg","thumbnailUrl":"localhost\/villalba2\/uploads\/Mobiliario\/thumbnail\/cama%20%282%29.jpg","deleteUrl":"http:\/\/localhost\/villalba2\/up\/server\/php\/?file=cama%20%282%29.jpg","deleteType":"DELETE"},{"name":"cama (3).jpg","size":101775,"url":"localhost\/villalba2\/uploads\/Mobiliario\/cama%20%283%29.jpg","thumbnailUrl":"localhost\/villalba2\/uploads\/Mobiliario\/thumbnail\/cama%20%283%29.jpg","deleteUrl":"http:\/\/localhost\/villalba2\/up\/server\/php\/?file=cama%20%283%29.jpg","deleteType":"DELETE"},{"name":"cama.jpg","size":101775,"url":"localhost\/villalba2\/uploads\/Mobiliario\/cama.jpg","thumbnailUrl":"localhost\/villalba2\/uploads\/Mobiliario\/thumbnail\/cama.jpg","deleteUrl":"http:\/\/localhost\/villalba2\/up\/server\/php\/?file=cama.jpg","deleteType":"DELETE"},{"name":"mantelera.jpg","size":50986,"url":"localhost\/villalba2\/uploads\/Mobiliario\/mantelera.jpg","thumbnailUrl":"localhost\/villalba2\/uploads\/Mobiliario\/thumbnail\/mantelera.jpg","deleteUrl":"http:\/\/localhost\/villalba2\/up\/server\/php\/?file=mantelera.jpg","deleteType":"DELETE"},{"name":"test (1).png","size":15,"url":"localhost\/villalba2\/uploads\/Mobiliario\/test%20%281%29.png","deleteUrl":"http:\/\/localhost\/villalba2\/up\/server\/php\/?file=test%20%281%29.png","deleteType":"DELETE"},{"name":"test (2).png","size":15,"url":"localhost\/villalba2\/uploads\/Mobiliario\/test%20%282%29.png","deleteUrl":"http:\/\/localhost\/villalba2\/up\/server\/php\/?file=test%20%282%29.png","deleteType":"DELETE"},{"name":"test.png","size":15,"url":"localhost\/villalba2\/uploads\/Mobiliario\/test.png","deleteUrl":"http:\/\/localhost\/villalba2\/up\/server\/php\/?file=test.png","deleteType":"DELETE"}]}
为什么不工作?图像上传到正确的文件夹:S
谢谢!
---最后一部分已经解决-----
编辑:
现在,拇指没有显示在浏览器上..
无法加载资源:服务器响应状态为404(未找到)/localhost/villalba2/up/localhost/villalba2/uploads/Mobiliario/thumbnail/mbiliario.jpg
正确的绝对路径:
/localhost/villalba2/uploads/Mobiliario/thumbnail/mbiliario.jpg
路径: / localhost / villalba2 / up /是blueimp jquery上传内核的地方
答案 0 :(得分:1)
定义常量
时必须使用引号define('DIR_DOWNLOAD', "/Applications/XAMPP/htdocs/villalba2");
然后json输出将是可解析的
答案 1 :(得分:1)
为了define constants,必须在定义中引用它们
define("DIR_DOWNLOAD", "/Applications/XAMPP/htdocs/villalba2");
define("HTTP_SERVER", "localhost/villalba2");
答案 2 :(得分:-1)
更改
tslint-fix