Passing file from jQuery Ajax method to Webservice - c#

I've a file upload control in my .aspx page. that file upload only allows excel files. after correct file is posted in that control. I'm rendering that control via JavaScript and passing that file to Web service, which has a method to access and do some calculation on that file.
I read some article for that. there is no such a functionality exist to transfer file via client side. Do you have any suggestion?

There is a HTML5 File upload, but only FF, chrome and Safari support these functions.
What you can do is using HTML5 upload with Flash or iFrame post as backup. A plugin with all browser support for jQuery can be found here.

Related

Docusign REST API to get document in envelope

I am creating a MVC web application with Docusign REST API.
I am going to create actionlink in index view for each record witch downloads
document in the record's envelope.
I am planning to use call following HTTP request.
GET /v2/accounts/{accountId}/envelopes/{envelopeId}/documents/{documentId}
When I call this request, I get pop up where I can choose location and name of file for the document that I am downloading.
Is there any way for me to pass folder location and name of file as parameter and download the file without getting this pop up?
I don't think Docusign does not provide such API to download in this way.
Thank you in advance.
A Web Server can not access the client's computer. Imagine if Google (or any other site) could just start programs on your machine when you visit their site! So popup has nothing to do with DocuSign.
So using DS API, you will get pdf as byte[], once you got byte[] then its your code who has to write it to a File and that is not possible on a WEBServer as WebServer will not be able to access the CLient's computer to directly save them on the machine without showing that popup. If you run below code in Standalone Java Application or I think Java Applets can also do it, then you can use FileOutputStream to write byte[] into a file directly in the machine.

C# download pdf from ajax driven url

In a C# application I would like to open a url and download a pdf.
When this url is hit from the browser the page quickly loads and begins what I believe are ajax calls. After several seconds the browser download prompt appears with the pdf file.
I have attempted to open this url via WebClient. The stream I return is not the pdf file and is is the actual html of the page.
How can I detect the the pdf file has loaded and download it?
If I'm not mistaken, WebClient has no clue about JavaScript, it won't run the AJAX code at all, it just gets the HTML of the page and leaves it at that.
And since likely the PDF's URL is parsed by the Javascript or the PDF is generated on demand or even streamed trough Javascript, you really need support for active content.
This seems something like Selenium would be good for. http://www.seleniumhq.org/
It'll spawn either an actual browser and steer that browser to the content you need or run the PhantomJS headless browser and fetch the content you want.
It might be a bit overkill and a more knowledgeable person might have a better answer, but that's what I've used on an application that needs to fetch PDF's, CSV's and other files from many different websites.

How to access clipboard image and save it at server location in asp.net web application?

I wish to have the following feature in my web application:
On the client side When I copy an image from anywhere (it gets loaded to the clipboard), now I wish to have a button on which when I click it should save the image at the server location at some path.
I am ok to use anything javascript, jquery, c# at server side code just need the implementation of the above feature.
Please help.
Thanks a lot in advance.
Vaibhav
Check out this question and answers to it: How does the paste image from clipboard functionality work in Gmail and Google Chrome 12+? .
I think the most difficult part is to get it working in all browsers. So if you need older browsers support you probably should use some flash solution like http://code.google.com/p/zeroclipboard/ .
To save it to server you need some controller's POST action (if using MVC) or webservice or aspx page if using webforms. After getting clipboard image with javascript you send it to the server using AJAX for example.

C# download web-content after submit

I need to automate the download of a file from this site http://stats.smith.com/reports/Default.aspx?btnGo=View+Report. My problem is once I click on the submit buttom I lose control and a download dialog pops up. Is there a way to download the file using c# and avoid the download dialog? I'm currently using the WebBrowser object in the Forms assembly to navigate through the page.
Take a look at the WebClient class
If you want to save a downloaded file to the filesystem from a web browser, there must be user interaction. A web page does not have permission to muck about in a client's file system.
If you want to display the page in the browser, you can try removing the Content-Disposition=attachment;... server response header when the file is downloaded. This will only work if the client has the browser set to display such file types inside the browser.
Your question doesn't specify what you're using to download the file.
If you're asking if you can have a program that runs on a client (either a WinForms app, a console app, or a Windows Service) then you can download a file from a web site using the System.Net.WebClient class and calling the DownloadFile() method.
The accepted answer here (slightly different than you question, so it's not a duplicate) has a link to show how to download a file that requires an HTTP post first.
If you're trying to somehow automate Internet Explorer via a javascript from a web page you're hosting to force a file to download on a user without displaying the dialog box, then no. You can't.

website to receive file upload from winform

I need to upload a file from a winform application to a website.
I have the winform side ready to go, I just need a little help with the webform side.
Client.UploadFile("http://xxx.yyy.com/data/", "sample.txt");
The file(s) that are to be uploaded, binary files, just need to be dumped into a subdirectory called data
I am stuck on the web page that will receive the file and save it into the directory.
c# and asp.net please
thank you
You don't need a web page for accepting the file being sent to server. Probably the easiest way would be to set up ftp on server and upload file there.
Sample code from msdn: http://msdn.microsoft.com/en-us/library/ms229715.aspx

Categories

Resources