Function:
1. Upload an image file (jpg gif png,
2. Save to the specified path (set the path in web. config and save it in the original file format ),
3. And automatically generate the specified width (set the width in web. config)
4. And the specified format (specify the thumbnail format in web. config)
5. Thumbnail with the same proportion as the original image (calculate the height of the thumbnail Based on the width and height of the original image)
6. You can determine whether a file already exists.
7. If not overwritten, an error is returned.
8. If "Overwrite source image" checkbox is selected, the source image is overwritten.
9. You can set more than one file input and the corresponding checkbox on webform as required.
10. After the file is uploaded, the file name, size, bytes, and
11. The size of the thumbnail file name.
12. File Name format of the thumbnail: the original image + "_ thumb." + specifies the format, for example, test.jpg_thumb.gif, for ease of management.
--------------------
Public void UploadFile (object sender, System. EventArgs e)
{
For (int I = 0; I <Request. Files. Count; I ++)
{
HttpPostedFile PostedFile = Request. Files [I]; // upload multiple Files
FileExt = (System. IO. Path. GetExtension (PostedFile. FileName). ToString (). ToLower (); // get the file extension and convert it to lowercase format
ImgNameOnly = System. IO. Path. GetFileName (PostedFile. FileName); // get the image file name
If (fileExt = ". jpg" | fileExt = ". gif" | fileExt = ". png ")
{
If (erroNumber> 0)
{
PicInfo. Append ("<font color = red> all operations have not been completed. Please modify the error before performing the operation </font> <br> ");
}
Else
{
For (int I = 0; I <Request. Files. Count; I ++)
{
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.