Hi
I’m trying to upload a file to my web-site using the code below.
I’ve marked where it crashes where it says:-
strFileName = Path.GetFileName(theImage.FileName); /* Crashing on this line !!!
I’m really stumped. Please can anyone get me going again.
This is my code :-
@{
var image = “”;
WebImage theImage = null;
var strFileName="";
var strImgPath="";
if (IsPost){
theImage = WebImage.GetImageFromRequest();
strFileName = Path.GetFileName(theImage.FileName); /* Crashing on this line !!!!!!!!!!!!!!!!!!!!
strImgPath = @"images\\" + strFileName;
theImage.Save(@"~\\"+strImgPath);
}
}
<!DOCTYPE html>
<html lang=“en”>
<head>
<meta charset=“utf-8” />
<title>The Matrix Man</title>
<link href=“StyleSheet1.css” rel=“stylesheet” type=“text/css” />
</head>
<body>
<!-- This is start of a new website that is going to reach new heights of design never seen before –>
<div id=“header”>
</div> <!-- end of header div –>
<div id="bodycontent">
<form action="" method="post" enctype="multipart/form-data">
Enter you file path to upload an image...
<input type="file" name="image" value="@image" />
<input type="submit" value="Upload" />
</form>
</div> <!-- end of bodycontent div -->
</body>
</html>
Cheers
Matt