我在服务器(centos)中创建文件夹时遇到问题,有一个带有文件上传字段的表单,其中ajax回调总是返回错误:
警告:mkdir():第90行/home/sitename/public_html/inc/callback/request_update.php中的权限被拒绝警告:move_uploaded_file(../../ images / listing / 16 / 805202.jpg):未能open stream:第95行/home/sitename/public_html/inc/callback/request_update.php中没有这样的文件或目录警告:move_uploaded_file():无法将'/ tmp / phpnrtrdp'移动到'../../ images /listing/16/805202.jpg'位于第95行的/home/sitename/public_html/inc/callback/request_update.php
并且它指示文件 request_update.php 中的行导致错误:
mkdir($ output_dir,0755,true);
request_update.php:
if(isset($_FILES['files'])){
foreach($_FILES['files']['tmp_name'] as $key => $tmp_name){
$file_name = $key.'_'.$_FILES['files']['name'][$key];
$file_size = $_FILES['files']['size'][$key];
$file_tmp = $_FILES['files']['tmp_name'][$key];
$file_type = $_FILES['files']['type'][$key];
//explode fine name and extension
$ext_x = explode('.', $_FILES['files']['name'][$key]);
$ext = strtolower(end($ext_x));
$file_name = str_replace('.'.$ext, '', $_FILES['files']['name'][$key]);
//new file name
$output_dir = '../../images/listing/'.$list_id;
$new_file_name[] = rand(1, 999999).'.'.$ext;
$pathfile = $output_dir.'/'.end($new_file_name);
// create directory if does not exist
if(is_dir($output_dir) == false){
mkdir($output_dir, 0755, true); /*this is where error indicate*/
}
if(is_dir($pathfile) == false){
if(move_uploaded_file($file_tmp, $pathfile)){
//watermark
$water_path = '../../images/watermark.jpg';
$watermark = WideImage::load($water_path);
//resize original image
WideImage::load($pathfile)->resize(300, 360)->merge($watermark, '50% – 25', '100% – 40', 80)->saveToFile($pathfile);
}
}
}
}
我已经尝试过在另一个共享服务器甚至localhost中运行相同的代码,该文件夹可以一直创建好,会发生什么?