在此,我有在PHP上提升形象的问题。
The problem is that when first time I upload the image file it works fine. But when I am trying to upload the file second time without page refresh it takes first image name and upload it.
问题是什么以及如何解决?
$name = $_FILES[ ImageFile ][ name ];
$size = $_FILES[ ImageFile ][ size ];
$tmp = $_FILES[ ImageFile ][ tmp_name ];
$path = "public/www/uploads/";
$valid_formats = array("jpg", "png", "gif", "bmp");
$response = ;
if(strlen($name)) {
list($txt, $ext) = explode(".", $name);
if(in_array($ext,$valid_formats)) {
if($size<(1024*1024)) {
$actual_image_name = time().substr(str_replace(" ", "_", $txt), 5).".".$ext;
if(move_uploaded_file($tmp, $path.$actual_image_name)) {
$response = "<img src= public/www/uploads/".$actual_image_name."?parm=".time()." class= preview >";
} else {
$response = "failed";
}
} else {
$response = "Image file size max 1 MB";
}
} else {
$response = "Invalid file format..";
}
} else {
$response = "Please select image..!";
}
此处,<代码>response是用来取得地位的变量。