Need to edge out the competition for your dream job? Train for certifications today.
string strFileName = "";
string strSavePath = "";
string strSaveDir = "";
bool bolOkToSave = 0;
// 1... Before attempting to save the file, verify
// that the FileUpload control contains a file.
// 2... get the uploaded filename and create save-paths
strFileName = FileUpload1.FileName;
strSaveDir = System.Web.HttpContext.Current.Server.MapPath("~/") + "img\\tmp\\"; // this path should exist on your server
strSavePath = strSaveDir + strFileName; // returns http://localhost/mysite/img/tmp/thefile.jpg
catch (Exception ex)
// handle any errors that occurred
try // again
// do nothing, it failed for some reason
// check again to see if the file was deleted
bolOkToSave = false;
// 3... Save the uploaded file to the tmp dir
Open in new window
Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.