Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So I have an HTML input of type file. I want to fire a method that posts the file to my ASMX web service using Ajax. I honestly have Googled and have no idea what to do. Here is what I have:

HTML
<script type="text/javascript">
        function Upload() {
            //Post data here
        }
    </script>

<input id="fuFile" type="file"  önchange="Upload()" />


I have no idea how to "extract" the file from the file input. Once it reaches my web service, I am going to need the byte[] of the file and the MIME type as I will then save this in the database.

Thanks for the help.
Posted

1 solution

1. Create a form.
2. Put your file input control inside that form.
3. Set the post url of the form to the webserver of your choice.
4. Get your javascript to call form's submit event.
 
Share this answer
 
Comments
DominicZA 26-Mar-12 8:35am    
Ok....now go and read my actual question, not just the header.
krumia 26-Mar-12 8:38am    
I read the header and the body as well. Thank you for telling me off for wasting my time to answer your rather unclear question.

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