我的问题在标题中。 我有一个将图像上传到服务器的表单,我想知道是否可以使用文件类型的if语句更改文件位置。
例如:
如果文件类型的图像比moveupload(../images);
其他,如果文件类型不是word {Docs或pdf moveupload(../xfile);
我还没有尝试过,只是想知道是否有可能,我还在学习。
这是我上传图片的代码:
$image_file = generatenewstring(12).$_FILES["ik_file"]["name"];
$type = $_FILES["ik_file"]["type"];
$size = $_FILES["ik_file"]["size"];
$temp = $_FILES["ik_file"]["tmp_name"];
$path="../images/".$image_file;
$directory="../images/";
if($image_file){
if($type=="image/jpg" || $type=='image/jpeg' || $type=='image/png' || $type=='image/gif'){
// Checking for image if exist we will delete this statment later on
if(!file_exists($path)){
if($size < 1000000){
// deleting old image
unlink($directory.$image);
// uploading new image
move_uploaded_file($temp, "../images/" .$image_file);
}else{
$ik_file_err = "Your File To large Please Upload 5MB Size";
}
}else{
$ik_file_err = "File Already Exists...Check Upload Folder";
}
}else{
$ik_file_err = "Upload JPG, JPEG, PNG & GIF File Formate.....CHECK FILE EXTENSION";
}
}else{
$image_file = $row['ik_file'];
}