|
i need to know how we can save the files that is loaded using the file upload control
|
|
|
|
|
Use the SaveAs method exposed by the control.
Paul Marfleet
|
|
|
|
|
no i mean that i write a web page this page contain as upload control i need som ideas that enable me to save the uploaded file from the other peoples on the internet into the server hard disk
|
|
|
|
|
I'm afraid I don't understand your question. What do you mean by 'other peoples'?
If you have a page that includes the ASP.NET FileUpload control, the user has to select a file. When the page is posted back to the server, you can programmatically work with the contents of the posted file.
If your question relates to some other mechanism of file upload, please be more specific about what you want to do.
Paul Marfleet
|
|
|
|
|
sorry for my bad language, yes what i want is to programmatically work with the contents of the posted file .
i try to upload some files from my website but when i check the server i didnot find the uploaded file so i assume that the control didnot work
i read from the internet that i need to applay some code when the page is submited to make the file upload control work
many thanks
|
|
|
|
|
You should post the code you have written so far and identify the section you are experiencing difficulties with. The exact nature of your problem still isn't clear to me.
The FileUpload control provides a means of acquiring a file from a client machine and including its contents in a HTTP server request. What happens to the contents of that file when the server receives the request is entirely up to the discretion of the programmer. As I have already stated, if you want to save the contents of the posted file on the server-side you need to call the SaveAs method of the FileUpload control.
Paul Marfleet
|
|
|
|
|
What u can do is use the SaveAs method to save the file to ur db as byte[] or just the filepath+filename.
Cheers
Bino
www.codepal.co.nr
|
|
|
|
|
drag n drop html browse control on your page rght click on it and check the "Run as Server Control" option now drag and drop a button on your form. Lets say the name(ID) of your File control is File1 then on click event of your button write following code
string path=@"C:\Uploaded";//Path where you want to save the uploaded file
File1.PostedFile.SaveAs(path);
You need to give ASPNET account write permissions on that folder where you want to save the file.
Shujaat
|
|
|
|
|
Hi
How do i add a "Installer Class" to my Web Project in VS 2005? When i right click on the project --> Add new Item, there is no "Installer Class".
ONeil
|
|
|
|
|
Why you want add an installer class? You don't have to add an installer project?
Visit my blog at http://dotnetforeveryone.blogspot.com
|
|
|
|
|
for loop
{
ImageButton img = new ImageButton();
img.ImageUrl = "a.gif";
img.Attributes.Add("onmouseover", "this.src='" + imgMouseOverURL + "'");
}
Hello, I have an imagebutton instance dynamically generated. The code works fine except the mouse over effect
on the button becomes a big red X everytime my mouse hovers over the image. Does this have something to do with the dynamic generation of my imageButton? On the contrary, if I have an imagebutton available in markup with similar attribute, everything works fine.
Please help.
Thank you.
Gerri
|
|
|
|
|
try doing a "View source" on the generated page to see what is actually sent down to the browser, and how it differs from the markup code that works
I'm not quite sure about your for...loop ? However you're looping, you can't create more than one control with the same ID...
Fred
|
|
|
|
|
|
CandyMe wrote: ImageButton img = new ImageButton();
img.ImageUrl = "a.gif";
img.Attributes.Add("onmouseover", "this.src='" + imgMouseOverURL + "'");
ImageButton accepts 'ImageUrl' attribute rather than 'Src' attribute which is an attribute for HTML Image.
Try modifying your last line of code to---
img.Attributes.Add("onmouseover", "this.ImageUrl='" + imgMouseOverURL + "'");
Hope this works
|
|
|
|
|
No, that's not right. The Attribute that that line adds is to the control as it is rendered client-side, and therefore you must use the client-side properties. The original code is right, in that respect.
|
|
|
|
|
|
Hi,
I am trying to create a setup program to deploy a .net 2 web app. When I right-click on the setup project and then go Add -> Project Output, I only see "Content Files" in the Add Project Output Group dialog box. Why do I not see the other options like "Primary output", "Localized resources", "Debug Symbols", etc.?
Any help would be greatly appreciated. Thanks in advance.
Regards,
|
|
|
|
|
Hello, I'm working on an internal e-mail utility to send messages to different groups from a database. One feature i'm implementing is the ability to add e-mail attachments. I have every thing working the way it should but it seems if a user tries to attach an Exe file, the page breaks.
for instance, if you had the file "breakit.exe" and tried to attach it, it would give me a "page cannot be displayed error" after I hit the "upload" button. if you try this with a .jpg, .txt, or anything it works, but the page breaks even if I try to change the name of "breakit.exe" to "breakit.notanexe".
Does any one know how to detect this problem before the page breaks?
thanks,
-Ian.M
if ((File1.PostedFile != null) && (File1.PostedFile.ContentLength > 0))
{
string fn = System.IO.Path.GetFileName(File1.PostedFile.FileName);
string SaveLocation = Server.MapPath("Data\\" + ParentSessionID.Value);
if (!System.IO.Directory.Exists(SaveLocation))
{
System.IO.Directory.CreateDirectory(SaveLocation);
}
try
{
File1.PostedFile.SaveAs(SaveLocation + "\\" + fn);
}
catch (Exception ex)
{
}
}
|
|
|
|
|
What do you mean by "the page breaks"? Where is the code sample you provided being run? Is this part of the code that handles the upload button?
If you don't want to allow executable files at all, you could probably use the System.IO.Path.GetExtension method to get the file extension. If the extension is ".exe", don't upload the file. Of course, this doesn't really prevent someone from uploading an executable, it just prevents them from using certain extensions.
|
|
|
|
|
Torin_DWC wrote: "page cannot be displayed error" after I hit the "upload" button
Have you tried setting a breakpoint and stepping threough to determine what the real error is? Its just that "Page cannot be displayed" is the generic error that is shown in the browser and provides no information for somebody trying to help you with this issue.
|
|
|
|
|
ya i got VS2005 here and I'm in debug mode but it's not stopping anywhere, I have break points at the top of Submit1_ServerClick which is what the upload button calls when it is pressed. This issue is only happening on exe files and exe files that have been renamed to other extentions. I'm guessing that something is looking at the file properties or file headers?
The strange thing is that it happens with all exe's, but not all exe's that have had their file extention changed.
so like:
iata76_enu.exe breaks page
iata76_enu.cheese breaks page
Silverlight.1.0.exe uploads fine
Silverlight.1.0.cheese uploads fine
NOTEPAD.EXE uploads fine
NOTEPAD.CHEESE uploads fine
Only reason I have that iata76_enu.exe is cause I was helping my coworker, otherwise I would never have run into this issue while testing the page.
-Ian.M
|
|
|
|
|
Ah then its obvious...nothing to do with exe and everything to do with filesize.
I'm willing to bet that iata76_enu.exe is substantially larger in filesize than notepad.exe
|
|
|
|
|
we have a winner, the thing dies if you try to upload a file greater than 5mb, but the strange thing is that this is not caught by the VS2005 debugger. I'll fiddle with it and see if I can check the file size once the openfile dialog is closed and before the user hit's the upload button :P
thanks again guys
-Ian.M
|
|
|
|
|
Hi Guys
Need help urgently. I am creating An Excel File Report Format. Data are read from SQLReader and insert into excel reports. However When i Generate the report the first time. It Can be successfully Generate but when i press the button to regenerate the report again it hit this error E_OUTOFMEMORY(0*8007000E)
Guys Please advise! Any method or solution
I am using asp.net 2.0 with ajax extension 1.0
KaKaShi HaTaKe
|
|
|
|
|
Did you configure ISS to use more memory?
|
|
|
|