function: Upload photos, display the upload time, image name, image size, picture description.
Description: 1. Some page space may not support the temporary file operation after uploading, it can only be a different try.
2. The program can automatically create new documents Photo.txt and directory image, if not working properly, please create a new document Photo.txt (and upimage.php in the same directory) and directory image.
3. You can test the http://medonline.51.net/upload/upimage.php on my homepage
-
<title>Uploading photos</title>
if ($upload) {//click "Upload" to execute this PHP code section
if ($picurl = = "None") {
echo "You didn't upload any files.";
Exit If the file is not uploaded, exit the program
}
$v =opendir ("image");
if ($v ==0)
{mkdir ("image");//If the directory does not exist, create a new
$v =opendir ("image"); Get catalog Handle
}
$up =copy ("$picurl", "image/$picurl _name"); A critical step to copy the temporary files to the image directory
if ($up ==1)
{
File operations
$FP =fopen ("Photo.txt", "a");//Open file, add to write message
Initialize Write content
$mydate =date ("Y year m D-day h:i A");
$phot//Convert a newline character to
。
$text = "Photo name: $picurl _name
Photo size: $picurl _size byte
Photo Description:
$photonote
Uploaded by: $user ($mydate) ";
Write content
Fwrite ($fp, $text, strlen ($text)); Strlin Calculating the string length of $text
Fclose ($FP);
echo "File Upload successful!
";
Unlink ($picurl); Delete the archive from the Temp folder $picurl
Closedir ($v); Close directory Handle
}
Else
{echo "File upload failed."; exit;} If the upload fails, exit the program
}
?>
All photos
|
Show previous upload photo information ReadFile ("Photo.txt"); ?>
|
Uploading photos
|
Return
|
"The copyright of this article is owned by the author and house Orso near net, if need to reprint, please specify the author and source"
The above describes the Shanghai Grand medical legend of the Chinese language PHP upload, management photos examples, including the Shanghai Grand Medical legend of the Chinese language content, I hope to be interested in PHP tutorial friends helpful.