Web Forms :: How To Save HttpPostedFile To Folder
May 7, 2015in my asp.net i need to convert httppostedfile to bmp or image format.how to convert this.am getting posted file from fileupload control.
Session["File"] = FileUpload1.PostedFile;
in my asp.net i need to convert httppostedfile to bmp or image format.how to convert this.am getting posted file from fileupload control.
Session["File"] = FileUpload1.PostedFile;
I have a standard FileUpload control, which calls a class library, where the file becomes HttpPostedFile. In beta versions of my page, I've been able to successfully use HttpContext.Current.Server.MapPath(filename)to save the file. The class library does various functions, including saving the image into /uploads and a thumbnail into/thumbs.
But now, after tidying up the layout of the site, the upload aspx page has moved to a subdirectory 'members'. I had assumed (wrongly) that calling the upload function would act as normal. However, now I receive an error because of where the page is originating from: The code wants to save the file in the non-existant folder /members/uploads and /members/thumbs
My question is: Apart from hard-coding the directory structure of my hosting provider, is there any way to use an equivilent to server.mappath which will recognise the root path of the website, and ignore sub-folders?
One method which solves my problem is to append "../" to the start of the file location, eg HttpContext.Current.Server.MapPath("../" & filename) ...However, as many pages will be able to call the upload class library (and not all of them in a sub-folder) I want to make sure I'm not always back-tracking on the subfolders.
How To Save Video files into folder and save path only into database in asp.net using c#.
View 1 RepliesWhat is the best way to insert and retrieve images like :
In the database in binary form retrieve it with imagehandler, or
In the database by saving the path of the folder of the images and retrieve it, or
by saving the images directly to the folder and retrieve it...
At present i am able to persist that using session InProc mode. except that i cant use either stateserver or sql server as the HTTPPostedFile is not serilizable. i can't use viewstate either for the same reason. Is there any work around to persist that httppostedfile across postbacks for session modes other than inProc or viewstate?
View 4 RepliesI need the following in c#.net
I need to save around 12 excel at a time in a particular folder in c#.net.
I used below code for uploading image and show in image control with thumpnail metod for reducing image size:
protected void BtnUpload_Click(object sender, EventArgs e)
{
string path = Server.MapPath(".") + "../image/House/product";
string filename = System.IO.Path.GetFileName(fup1.PostedFile.FileName);
string[] validext = { ".jpg", ".png" };
string ext = System.IO.Path.GetExtension(fup1.PostedFile.FileName);
if (Array.IndexOf(validext, ext.ToLower()) < 0)
[Code]...
It save original image in host, now I want it save image that reduce size with GetThumpnail metod in other place How I can do it?
I m uploading a file and reading it. The problem is I dont want to save that file in a folder which is in my solution explorer. I want to save it in a different Drive. I m saving the file in a different drive using web.cofig <add key="UploadFileLocation" value="C:\VOL0\Upload\"/> and I m saving using code FileUpload1.PostedFile.SaveAs(ConfigurationManager.AppSettings["UploadFileLocation"] + SaveLocation); all goes fine, but I m reading the file and it is throwing an exception when I m trying to read file.
View 3 RepliesCurrently i have done upload image function and its saved the picture into folder in server . But if the picture has same name its unable to save the photo . How to rename the photo each time i save the photo into the server . Below is my coding .
<asp:FileUpload ID="FileUpload1" runat="server" />
<input type="button" id="btnUpload" runat="server" value="UploadPhoto" onserverclick="btnUpload_Click" />
protected void btnUpload_Click(object sender, EventArgs e)
[Code]....
How i can download image from sql server and store in a folder?
View 1 RepliesHow to convert a asp panel to a pdf file and save that in a particular project inside the website itself?
View 1 RepliesI was watching the page [URL] .... and its great , but I would like to use the example but i need a textboxt to input the folder that i want to use to save the images
destination folder: upload/
<input id="Text1" type="text" value="my folder" /><br />
<a href="javascript:$('#<%=FileUpload1.ClientID%>').fileUploadStart()"
style="font-family: Arial; font-size: medium; color: #008000;">Start Upload</a>
| <a
href="javascript:$('#<%=FileUpload1.ClientID%>').fileUploadClearQueue()"
[Code] .....
I want to upload images in to a folder in my project and save the URL in the database.
When you add a record into my database you provide title, date added and some other details and there it a file upload control which you browser to a image and it saves the image to a folder in my project, it all works, the record is added and the image is uploaded into the folder, but the problem I have is that there is no link from the record to the image, there is no URL path saved in the record. How do I save the image in the folder and save the URL of the image to the record?
I'm using details view to insert the records and using grid view to view the records.
I used below code to upload image and put watermark on it
protected void BtnUpload_Click(object sender, EventArgs e) {
uploadImageError.Visible = true;
if (fup1.HasFile && fup1.PostedFile.ContentLength < 102400) {
string watermarkText = "behtop.com";
string path = Server.MapPath("~/image/House/product/");
[Code] ....
Problem is when I upload image and click on btnupload it shows image in new window with watermark text but it doesn't save it into host...
I want when I click on btnupload it doesn't show image in new window I want it just uploaded image with watermark into host...
How I can do it?
I was wondering whether HttpPostedFile.SaveAs function in ASP.NET C# is a blocking call.
View 1 RepliesI want to load a image in drive in images folder.I created one folder in the d drive by the name Images
In button save event...
string path = ConfigurationManager.AppSettings["LoadImage"].ToString();
In Web Config why is this not working
<add key="LoadImage" value="D:Images"/>
i m using asp.net 2005 with access 2003. with the fileupload control, i can store the vlc player in my folder by using tis code
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
If FileUpload1.HasFile Then
FileUpload1.SaveAs(Server.MapPath("upload/" & FileUpload1.FileName))
Label1.Text = FileUpload1.FileName.ToString
con.Open()
Dim dat As String
dat = Now()
Dim cmd As New OleDbCommand("insert into filenms values('" & Label1.Text & "','" & dat & "' ) ", con)
MsgBox("Updated")
Try
cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox("type correct Text and not updated")
End Try
End If
End Sub
but it is showing me " The page cannot be displayed ". how can i store
I want to save file in particular folder .
how can i do this ?
i want to save a picture in one folder up from there where i call the mappath how can i do that?
for example i am here
c:usersmevstproject
and i want to save the file here
c:usersmevst
i want to do that with mappath in order to work in the server.not only in my pc..
how to zip the folder and ask for the open save prompt in c#.net
View 1 RepliesI had a code that creates a snapshoot of website and store the snapshoot in a specified folder.When I deployed the app into production server, it creates the image but it does not appear or stored in the specified folder, how I can fix this proble, I wan the snapshoot to be stored in the specified folder when hte app is on the production server .
Code Used to make a snapshoot is attached:
[URL]
I write code for save my Image file in one folderThe code as follow :SavePath = Server.MapPath("~/images/masterpageimage/");MasterFile.Save(SavePath + fname);This code perfectly run in my local machin but when I upload this codeto my server it give me error asxception Details: System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
View 1 RepliesI am Generating a Word Document by using Following Code:
StringBuilder str1HTMLContent = new StringBuilder();
str1HTMLContent.Append("<html>".ToString());
str1HTMLContent.Append("<body>".ToString()); [code]....
The word file is Created and popup on windows .How can i save this created word Document on Database, or on server folder?
I have the problem to upload Image.i want to save image in folder with the name of userId existing in sql server 2005 DB.
View 2 RepliesI want to save zipped file on server disk using DotNetZip in ASP.Net .... This code creates zip and download it in client side download folder..
ZipFile zip = new ZipFile();
List<Attachment> listattachments = email.Attachments;
int acount = attachments.Count;
for (int i = 0; i < acount; i++)
[Code] ....