這是我的圖片上傳頁面。我想要的是位版本。我想形象的名字看起來像(文件夾)的圖像/ userid_time.jpg將圖片上傳至圖片文件夾並以獨特名稱
,所以我要上傳圖片到圖片文件夾,
,我希望所有的圖像有新的名稱,或者我們可以說唯一的名稱。
在此請求任何adition。
<?php // upload2.php
echo <<<_END
<html><head><title>PHP Form Upload</title></head><body>
<form method='post' action='upload2.php' enctype='multipart/form-data'>
Select a JPG, GIF, PNG or TIF File:
<input type='file' name='filename' size='10' />
<input type='submit' value='Upload' /></form>
_END;
if ($_FILES) {
$name = $_FILES['filename']['name'];
switch ($_FILES['filename']['type']) {
case 'image/jpeg':
$ext = 'jpg';
break;
case 'image/gif':
$ext = 'gif';
break;
case 'image/png':
$ext = 'png';
break;
case 'image/tiff':
$ext = 'tif';
break;
default:
$ext = '';
break;
}
if ($ext) {
$n = "image.$ext";
move_uploaded_file($_FILES['filename']['tmp_name'], $n);
echo "Uploaded image '$name' as '$n':<br />";
echo "<img src='$n' />";
} else
echo "'$name' is not an accepted image file";
} else
echo "No image has been uploaded";
echo "</body></html>";
?>
謝謝:)
很好,謝謝:) – deerox