我尝试在上传后将文件存储到文件夹中,但不起作用

zzzyeukh  于 2021-07-24  发布在  Java
关注(0)|答案(0)|浏览(143)

这段代码在localhost上运行得很好,但是在线上传后,数据存储在数据库中,但文件不能存储在文件夹中。
声明图像

//Property image
$cimage=$_FILES["image"]["name"];
$extension1 = substr($cimage,strlen($cimage)-4,strlen($cimage));

允许的扩展

$allowed_extensions = array(".jpg",".jpeg",".png",".gif");

验证

// Validation for allowed extensions .in_array() function `searches an array for a specific value.`
if(!in_array($extension1,$allowed_extensions))
{
echo "<script>alert('Image has Invalid format. Only jpg / jpeg/ png /gif format allowed');</script>";
}

else
{

文件目录为images/cimage
重定时图像

$image=($cimage);   
move_uploaded_file($_FILES["image"]["tmp_name"],"images/cimage".$image);
$ret="select title from property where title=:title";
 $query= $dbh -> prepare($ret);
$query->bindParam(':title',$title,PDO::PARAM_STR);
$query-> execute();

$results = $query -> fetchAll(PDO::FETCH_OBJ);

 if($query -> rowCount() == 0)

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题