Problem:
You want to be able to POST a file from a generic HTML form to a generic ASP.NET handler (.ashx).
Solution:
First, make sure that your file input control on your HTML form has a name. If it doesn't have a name, you won't be able to access the file on the server side and it will appear not to have uploaded.
<input name="uploadedFile" id="uploadedFile" type="file" />
Second, make sure that your form action has an enctype parameter set to "multipart/form-data."
<form action="Upload.ashx" method="post" enctype="multipart/form-data" />
Now in your HTTP handler, you can either access that file by the name you provided it on the form:
context.Request.Files["uploadedFile"]
...or you can iterate through the files by key...
foreach (string f in context.Request.Files.AllKeys)
{
context.Request.Files[f].SaveAs(
HttpContext.Current.Server.MapPath("~/App_Data/" + ...));
}
Rom's Rants
Free-Roaming Hostility From A QA/Developer Perspective.
April 25, 2012
March 27, 2012
Forgive the silence...
Sorry that I've been so silent this month. Between my grandmother passing at the beginning of the month and me scrambling to catch up from work after getting back from the funeral, I'm not exactly on top of my game.
I'm hoping to return in force in April.
I'm hoping to return in force in April.
February 8, 2012
Back In Action
My machine is set up in a temporary location in the new condo now, and I've already found the root cause for several of the issues that have been affecting people in RomTerraria.
I'll have the patch up either tonight or tomorrow. Keep those auto-updaters ready...
Also, does anyone know if the retail version of Terraria will require Steam or not? I need to know so I can properly update my protection mechanism to work with retail.
I'll have the patch up either tonight or tomorrow. Keep those auto-updaters ready...
Also, does anyone know if the retail version of Terraria will require Steam or not? I need to know so I can properly update my protection mechanism to work with retail.
January 24, 2012
Move (Almost) Complete
The movers will be at my condo sometime within the next hour to unload the truck containing all my belongings. It will take a few additional days to get unpacked and settled, but I can't wait to get back into the swing of things.
Subscribe to:
Posts (Atom)