Warning: include_once(/home2/idlequot/public_html/TECHNODOULIA.COM/wp-content/plugins/wp-super-cache/wp-cache-phase1.php): failed to open stream: Permission denied in /home/technodoulia/public_html/wp-content/advanced-cache.php on line 14

Warning: include_once(): Failed opening '/home2/idlequot/public_html/TECHNODOULIA.COM/wp-content/plugins/wp-super-cache/wp-cache-phase1.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/technodoulia/public_html/wp-content/advanced-cache.php on line 14
Fileupload Control To Take .jpg Only | Technodoulia

Fileupload Control To Take .jpg Only

Fileupload control in asp.net is used to upload different file from your computer to server. In the previous article you come to know about how we can limit the size of fileupload control.

Now in this article we restrict fileupload control to take only ¬†“.jpg” format images.

string extfileupload = System.IO.Path.GetExtension(this.FileUpload1.PostedFile.FileName);
if (extfileupload.ToUpper().Trim() != “.JPG” || extfileupload.ToLower().Trim() != “.jpg”)
ClientScript.RegisterStartupScript(this.GetType(), “myalert”, “alert(‘Image format should be in .jpg only’);”, true);

// your code to upload image



By that way we find first the extension of file and store it in string then we make condition for that image extension.

Leave a Reply