php上传图片
在网页中我想先来个预览 比如说我刚上传的图片在网页中显示 该怎么办啊 不应该echo ""; 这样写吗? 哪该怎样写啊
用上传时间命名图片 该如何改写代码
if (is_uploaded_file($_FILES['upfile']['tmp_name'])){
$upfile=$_FILES["upfile"];
$name = $upfile["name"];
$type = $upfile["type"];
$size = $upfile["size"];
$tmp_name = $upfile["tmp_name"];
$error = $upfile["error"];
switch ($type) {
case 'image/pjpeg' : $ok=1;
break;
case 'image/jpeg' : $ok=1;
break;
case 'image/gif' : $ok=1;
break;
case 'image/png' : $ok=1;
break;
}
if($ok && $error=='0'){
move_uploaded_file($tmp_name,'up/'.$name);
echo "上传成功";
echo "$name
";
echo "$type
";
echo "$size
";
echo "$tmp_name
";
}
}
?>