Click here to Skip to main content
15,912,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i have a problem in code.
look at the lines given below
C#
string target;
FileUpload1.FileContent.Seek(0, SeekOrigin.Begin);
FileUpload1.PostedFile.InputStream.Read(pic, 0, len);


where FileUpload is a tag in asp.net use to upload a file. the string target has assigned a jpeg file. now i want to use the string target in place of Fileupload can somebody tells me how to use it, or any alternative for that?
thnx
Posted
Updated 26-Oct-11 21:20pm
v2

For saving a file from a fileUpload, the easiest way is :
if(FileUpload1.HasFile)
      FileUpload1.SaveAs(target);

You have to initialize target with a correct filename according your needs.
 
Share this answer
 
v2
Comments
saifullahiit 27-Oct-11 5:21am    
i dont want to use FileUpload1 coz i have a ppt file that has been converted to images i have used the loop that converts the ppt slide one by one into an image, assign that image to string target and save it in the db. so for that purpose i dont want to use fileupload1.
Yuri Vital 27-Oct-11 5:43am    
Your question doesn't contains this all information. Moreover in your exemple you use FileUpload1 ... So be coherent !
saifullahiit 27-Oct-11 6:10am    
here is the complete code:
it is for saving it into db
protected void Button1_Click(object sender, EventArgs e)
{
ApplicationClass pptApplication = new ApplicationClass();
Presentation pptPresentation = pptApplication.Presentations.Open("saifullah.ppt", MsoTriState.msoFalse,
MsoTriState.msoFalse, MsoTriState.msoFalse);

var slides = new List<string>();
for (var i = 1; i <= pptPresentation.Slides.Count; i++)
{
string target = i+".jpeg".ToString();

pptPresentation.Slides[i].Export(target, "jpg", width, height);

string pic = target;



con.Open();
cmd = new SqlCommand("insert into images values('"+@pic+"')",con);
cmd.ExecuteNonQuery();
con.Close();

}

pptPresentation.Close();
}


and it is for retreiving from db
MemoryStream stream = new MemoryStream();
try
{
con.Open();
cmd = new SqlCommand("select pics from images", con);
byte[] image = (byte[])cmd.ExecuteScalar();

stream.Write(image, 0, image.Length);

Image imag = Image.FromStream(stream);
Response.ContentType = "image/JPEG";
imag.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
}
finally
{
con.Close();
stream.Close();
}
In response of your comment in Solution 1, i give you somme more precise explanation.

I suggest you to :
1°) save the file like mentionned in Solution 1
2°) parse the saved ppt file in jpg file like described in this link

http://stackoverflow.com/questions/2972263/ppt-slides-to-images[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900