I'm trying to use Uploadify in a ASP.NET webforms project. The problem is that my script is not calling the generic handler. Here is the script.
<input id="fileInput" name="fileInput" type="file" /> <script type="text/javascript"> $(document).ready(function() { $('#fileInput').uploadify({ 'uploader': '/Ferramenta/Comum/Uploadify/uploadify.swf', 'script': 'UploadTest.ashx', 'cancelImg': '/Ferramenta/Comum/Uploadify/cancel.png', 'folder': "/Ferramenta/Geral/", 'auto': true, 'onError': function(event, queueID, fileObj, errorObj) { alert('error'); }, 'onComplete': function(event, queueID, fileObj, response, data) { alert('complete'); }, 'buttonText' : 'Buscar Arquivos' }); }); </script>
This is the code of the generic handler (just to test)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.IO;
namespace Tree.Ferramenta.Geral
{
public class UploadTest : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.Write("1");
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
Any ideas ? Thanks !
You can check if the namespace for the handler class (UploadTest.ashx) is the same in the markup and code behind – for me it was the thing causing the same problem.
Put a breakpoint in
ProcessRequest
.. does it fire?If your website content is not public, add to
web.config
authorization access to the Handler, in order to avoidHTTP Error
Have you tried the code on IE and Firefox? If you only get this problem with Firefox, try creating a Global.asax with the following code (I just have the code in VB.NET):
And then call uploadify like this:
Browse directly to your .ashx file, do you get any errors?
Download firebug, and check to see if you are receiving any javascript errors as well.
You might also want to add:
Is your site on SSL? I had the same problem and it turned out it was because I had an invalid certificate. Something to do with Flash burying an error if you are uploading a file with a bad cert.