I have a SWFUpload on my page, I click the button and the file selct window comes up, I select a file but I do not know how to get the filename that was uploaded? and I dont even know if the file is being uploaded.
Can anyone help me please?
I am using ASP.NET VS2010
I am currently working on swfupload but in java. I may be able to answer your question.
So after you select a file, the flash upload will prepare your files for upload. It will send the request to the upload_url. This call to upload_url is like sending a request with a
< input type="file" name="Filedata"/ > so you can access your file if you get the Filedata after the multipart post. In other words, its just like an html page uploading your files.
Let me know if you need more help.
Related
I have a requirement of reading the content of PDF file from browser using c# and then save it locally. There is no physical existence to that file. It is served when file code is provided using the query string. The sample url is like http://something/ReportStatus.aspx?indvl_pk=12334. I am getting no way to do that. Any help is appreciated. Thanks is advance.
I'm trying to download files directly from a list of urls.
I was able to download most files successfully except for the .docx. I was able to download the .docx file, but when I try to open it, the error message shows that "The file is corrupt and cannot be opened", when I try to repair it with Microsoft Word, I got another error message saying "Microsoft Office cannot open this file because some parts are missing or invalid". I don't have any issue when download pdf files.
My code is very simple and it looks like this:
WebClient webClient = new WebClient();
webClient.DownloadFile("http://somehost/somefile.docx", "C:\\somefolder\\somefile.docx");
webClient.Dispose(); //I added this line just to see if it will fix the problem but no it didn't
I went to the urls in the browser and make sure that the files does exist and are not corrupted. The urls are just fine and I was able to download files directly from the urls in a browser and the file opens.
Additional Information:
I did find one thing that's different for pdf url and docx url, but I really don't think it has anything to do with my problem. When I go to the pdf url in a browser, the pdf was displayed in the browser. However, when I go to the docx url, the page doesn't show anything, but the download for the file automatically starts. I don't think this will make a difference but just FYI.
EDIT 10:38AM
I just tried the Async method. I was able to download the docx file and open it, but it appear as a blank word document, which is still not correct. The same docx file I download from the browser does have content.
webClient.DownloadFileAsync(new Uri("http://somehost/somefile.docx"),"C:\\somefolder\\somefile.docx");
DownloadFileAsync downloads file in background, and your application probably terminates before download is completed.
You should wait for DownloadFileCompleted event, or use a DownloadFile method that will wait until file will be downloaded.
Thank you everyone for trying to help, I really appreciate it.
I realize that the problem was actually me not concatenating the url correctly. Right, a stupid mistake I made...
WebClient didn't throw error for incorrect format (for whatever reason), and my log file was not logging the actual url that I was trying to connect to, so I didn't realize it was doing the wrong thing.
Anyway, thank you all for the help and the comments that help me figure out what the problem was.
I need to automate downloading of a file from this site http://stats.smith.com/reports/Default.aspx using C#. The problem is that a web-form needs to be submitted first then the download takes place immediately. I can simulate the web form submit and the buttom clicks. However, once the form is submitted I don't know how to capture requested file. There is no redirection to the uri of the downloaded file. If there was I would have used function download(uri, filename) in webclient or webbrowser.
If you use the WebRequest Class you can receive the response and save it as a file.
I have a page that downloads a large HTML file from another domain then serve it to the user. The file is around 100k - 10MB and usually takes about 5min. What was think about doing something like this to make the user experience better.
download file
if file is not download within 10 seconds then displays a page that tells the user that the file is being downloaded
if the server completes the download in 1 second then it will serve the downloaded html
can this be done? do I need to use the async feature?
Updated question: the downloaded file is a html file
In order to provide an 'asynchronous' file download try a trick that Google is using: Create a hidden iframe and set it's source to the file you want to download. You can then still run javascript on your original page while the file is being downloaded through the iframe.
I think you should:
Return an HTML page to the user straight away, to tell them the transfer has started.
Start the download from the other domain in a separate process on your server.
Have the HTML from step 1 repeatedly reload, so you can check if the download has completed already, and possibly give an ETA or update to the user.
Return a link to the user when the initial transfer is complete.
It sounds like you need to use a waiting page that refreshes itself every so often and displays the status of your download. The download can be run on a separate thread using a System.Threading.Task, for instance.
Dear friends
I have a console application in which i want to first sign in and then I press button which directs me to file upload form .In file upload form I want to upload a csv file and then redirect to next form after clicking submit button then i want to get response of that form .
can any one help me to do this from C# console application?
thanks.
if you want to upload a file on a website from a console application,
then you should have information about FTP credentials.
If you want to do a real http-transfer you need to create a http request, I looked around a little bit and found this: Upload files with HTTPWebrequest (multipart/form-data), seems to be right. I'm doing something similar in python currently.