Using Uploadify with Sharepoint and .net

I have some html generated by jQuery on the Share Point page. I want to use uploadify in this html to upload a file to the server. Alexander helped provide the following code example, which is partially based on http://www.uploadify.com/forum/viewtopic.php?f=5&t=45 .

upload.ashx

<%@ Assembly Name="ClassName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f099e668beaaa0f9" %> <%@ WebHandler Language="C#" CodeBehind="Upload.ashx.cs" Class="Site.RootFiles.TEMPLATE.LAYOUTS.other.Upload" %> 

upload.ashx.cs

 public class Upload : IHttpHandler { public void ProcessRequest(HttpContext context) { HttpPostedFile oFile = context.Request.Files["Filedata"]; if (oFile != null) { const string sDirectory = "c:\\"; if (!Directory.Exists(sDirectory)) Directory.CreateDirectory(sDirectory); oFile.SaveAs(Path.Combine(sDirectory, oFile.FileName)); context.Response.Write("1"); } else { context.Response.Write("0"); } } public bool IsReusable { get { return false; } } } 

The file does not upload to the server. The only event that throws is onProgress. Going to _layouts / other / Upload.ashx returns 0 (this is correct), so there is a file.

The main question is: how do I get this to play with the exchange point? I am trying to remotely debug the upload.ashx file, but it will not allow me to add breakpoints in VS, so remote debugging does nothing.

Update 1

This question Debugging Visual Studio ASHX files got debugging work.

When I go directly to page 0, it is written to the page. The debugger works, and everything is fine. When the script runs it without hitting Upload.ashx as breakpoints do not hit. I believe my link to Upload.ashx is incorrect. I tried using http: //mysite/_layouts/other/Upload.ashx in js and still not a joy ...

Update 2

After some testing, the problem is that it asks me to re-enter Share Point (I am logged in). This makes him make the trip. Any ideas how to make sure my authentication is raised?

Update 3

This is really weird. I am tempted to say that this is a setting in my IE8 that does this as it works for a team assistant.

When I look directly at /_layouts/other/Upload.ashx, I never ask for authentication. When I go through JS, they sometimes ask me to confirm, even if I logged in earlier.

+4
source share
1 answer

You are not loading into the page, but into the http handler . You must add the code that you pasted into upload.ashx as indicated in the forum post. Then, on the client, use uploadid as follows:

 $("#fileInput1").uploadify ({ script: 'upload.ashx' }); 
+1
source

All Articles