Php photo upload and management example

Source: Internet
Author: User
Php Upload and manage Photo Examples & lt ;! -- Upload photo example upimage. php <br/> function: upload a photo to show the uploaded person, upload time, image name, image size, and image description.



Upload photo



If ($ upload) {// if you click "upload", run the php code section
If ($ picurl = "none "){
Echo "you have not uploaded any files .";
Exit; // exit the program if no file is uploaded
}
$ V = opendir ("image ");
If ($ v = 0)
{Mkdir ("image"); // if the directory does not exist, create
$ V = opendir ("image"); // Get the directory handle
}
$ Up = copy ("$ picurl", "image/$ picurl_name"); // The key step is to copy the temporary file to the image directory.
If ($ up = 1)
{
// File operations
$ Fp = fopen ("photo.txt", "a"); // open the file and write the message as an addition.
// Initialize the written content
$ Mydate = date ("Y, m, d, h: I ");
$ Photonote = nl2br ($ photonote); // convert the line feed
.
$ 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 calculates the string length of $ text
Fclose ($ fp );
Echo "file uploaded successfully!
";
Unlink ($ picurl); // delete a file from a temporary folder $ picurl
Closedir ($ v); // Close the directory handle
}
Else
{Echo "file Upload failed."; exit;} // exit the program if the upload fails.
}
?>














All photos

// Display previous uploaded photo information
Readfile ("photo.txt ");
?>

Upload photo


Return




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.