php上传文件保存位置,php - 要更改PHP中已上传文件的保存文件夹路径吗? - SO中文参考 - www.soinside.com...

如何更改在服务器上上传图像的目录。我正在尝试生成一个基于用户输入来创建页面的应用程序。

我想在以下位置创建文件夹:"".$_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);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值