I get this two messages while I try to upload an image:
Warning: move_uploaded_file(/images/uploads/2014-02-28_17:39:37-Untitled-1.png) [function.move-uploaded-file]: failed to open stream: Invalid argument in D:\\AppServ\\www\\my\\addpost.php on line 23
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\\Windows\\Temp\\php13A7.tmp' to '/images/uploads/2014-02-28_17:39:37-Untitled-1.png' in D:\\AppServ\\www\\my\\addpost.php on line 23
this is my code:
$name = date("Y-m-d_H:i:s").'-'.$_FILES['image']['name'];
$type = $_FILES['image']['type'];
$temp = $_FILES['image']['tmp_name'];
$uerror = $_FILES['image']['error'];
list($width, $height) = @getimagesize($_FILES['image']['tmp_name']);
$maxhight = 1;
$maxwidth = 1;
if ($error == 0) {
if(($height > $maxhight) or ($width > $maxwidth)){
move_uploaded_file($temp,"/images/uploads/".$name);
}else{
$error = "Just you can upload photos!!";
}
}else {
$error = "error while uploading : " . $uerror;
}
note :
/images/uploads/
folder is already exist
You using :
in directory name. Try change your directory name:
$name = date("Y-m-d_H:i:s").'-'.$_FILES['image']['name'];
into this:
$name = date("Y-m-d_H-i-s").'-'.$_FILES['image']['name'];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.