如何更改在服务器上上传图像的目录。我正在尝试生成一个基于用户输入来创建页面的应用程序。
我想在以下位置创建文件夹:"".$_POST['property_builder']."/".$_POST['property_city'].""."/".$_POST['property_location']."/".$_POST['property_type'] . '/'
并存储。extract($_POST);
$error=array();
$extension=array("jpeg","jpg","png","gif");
foreach($_FILES["files"]["tmp_name"] as $key=>$tmp_name) {
$file_name=$_FILES["files"]["name"][$key];
$file_tmp=$_FILES["files"]["tmp_name"][$key];
$ext=pathinfo($file_name,PATHINFO_EXTENSION);
if(in_array($ext,$extension)) {
if(!file_exists("photo_gallery/".$txtGalleryName."/".$file_name)) {
move_uploaded_file($file_tmp=$_FILES["files"]["tmp_name"][$key],"photo_gallery/".$txtGalleryName."/".$file_name);
}
else {
$filename=basename($file_name,$ext);
$newFileName=$filename.time().".".$ext;
move_uploaded_file($file_tmp=$_FILES["files"]["tmp_name"][$key],"photo_gallery/".$txtGalleryName."/".$newFileName);
}
}
else {
array_push($error,"$file_name, ");
}
}
$file = fopen("".$_POST['property_builder']."/".$_POST['property_city'].""."/".$_POST['property_location']."/".$_POST['property_type'] . '/' . $file_to_write,"w");
fwrite($file, $content_to_write);
// closes the file
fclose($file);