Upload files with jqxFileUpload to ASP.NET web service
In this help topic we are going to show you how to connect jqxFileUpload to ASP.NET web service.
- Create a new ASP.NET Empty Web Application.
- Add the following files to the Scripts folder.
jqxcore.js, jqxbuttons.js, jqxfileupload.js and jquery-1.11.1.min.js.
- In the "Styles" folder add the "jqx.base.css" CSS file.
- Add a new web service to the website. Right click on your project’s name. Then choose "Add -> New Item -> Web Service". For example call it "FileUpload". This will create a FileUpload.asmx file which we will use for the serverside code to handle our file upload.
Add these additional dependancies after the already included ones:
Use the following code for the [WebMethod] section
This page will be responsible for the post requests sent by our client page. It is configured to accept image mime types, and only with extensions .jpg, .jpeg, .bmp, .png and .gif. It works for single and multiple uploads since jqxFileUpload sends the files one by one.
You need to create a folder named "uploads" inside the project directory to store the uploaded files.
Now let's add an example.htm file to our project to test the page with the following code.
The uploadUrl parameter must point to the WebService file and the UploadFile method we created above.
While having the example.htm file active in the solution explorer press F5 in Visual Studio to run and test your project.