I have a input div with a form to upload a picture. That works fine! but the input file clears all the other inputs :(
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="Image" />
<br/>
<input type="submit" value="Upload" />
<br/>
<br />
@if (imagePath != ""){
<div class="result" style="margin-top:-50px; padding-left:100px">
<img src="@imageThumbPath" alt="image" />
<input id="Omsimagefile" value="@newFileName" style="display:block"/>
</div>
}
</form>
With the ajax post will the data updated The file is updated in the map /..
How can i upload the image without page refresh?
Rezise the Image:
WebImage photo = null;
var newFileName = "";
var imagePath = "";
var imageThumbPath = "";
if (IsPost)
{
photo = WebImage.GetImageFromRequest();
if (photo != null)
{
newFileName = Path.GetFileName(photo.FileName);
imagePath = @"/Images/OmsObject/" + newFileName;
photo.Resize(width: 400, height: 300, preserveAspectRatio: true,
preventEnlarge: true);
photo.Save(@"~/" + imagePath);
imageThumbPath = @"/Images/OmsObject/Thump/" + newFileName;
photo.Resize(width: 120, height: 80, preserveAspectRatio: true,
preventEnlarge: true);
photo.Save(@"~/" + imageThumbPath);
}
}