2010-03-23 111 views
14

這看起來應該很容易,但我一直無法使它工作。我不知道爲什麼它不。它只是顯示正常的文件輸入。上傳Uploadify使用C#

有沒有任何代碼/例子來得到這個工作。我感到沮喪...

謝謝大家。

+1

什麼是uploadify?你有什麼問題?你有試過的自己的示例代碼嗎? – 2010-03-23 15:17:40

+0

jQuery插件,我認爲... – hunter 2010-03-23 15:17:58

+0

Uploadify很棒。 @JoelMartinez:http://www.uploadify.com/ – 2010-03-23 15:22:45

回答

19

這是關於如何開始使用C#和Webforms的視頻教程,應該對您有所幫助。

http://casonclagg.com/articles/6/video-tutorial-uploadify-asp-net-c-sharp.aspx

您可以發佈您的代碼,雖然這樣我也許能告訴你什麼是你做錯了什麼?

下面是示例代碼,我有asp.net

<script type="text/javascript"> 
     // <![CDATA[ 
     var id = "55"; 
     var theString = "asdf"; 
     $(document).ready(function() { 
     $('#fileInput').uploadify({ 
     'uploader': 'uploadify/uploadify.swf', 
     'script': 'Upload.ashx', 
     'scriptData': { 'id': id, 'foo': theString}, 
     'cancelImg': 'uploadify/cancel.png', 
     'auto': true, 
     'multi': true, 
     'fileDesc': 'Image Files', 
     'fileExt': '*.jpg;*.png;*.gif;*.bmp;*.jpeg', 
     'queueSizeLimit': 90, 
     'sizeLimit': 4000000, 
     'buttonText': 'Choose Images', 
     'folder': '/uploads', 
     'onAllComplete': function(event, queueID, fileObj, response, data) { 

     } 
    }); 
    }); 
    // ]]></script> 

    <input id="fileInput" name="fileInput" type="file" /> 

然後你想一個處理程序(ashx的):

public class Upload : IHttpHandler, IRequiresSessionState 
{ 

    public void ProcessRequest(HttpContext context) 
    { 
     try 
     { 
      HttpPostedFile file= context.Request.Files["Filedata"]; 

      int id = (Int32.Parse(context.Request["id"])); 
      string foo = context.Request["foo"]; 
      file.SaveAs("C:\\" + id.ToString() + foo + file.FileName); 

      context.Response.Write("1"); 
     } 
     catch(Exception ex) 
     { 
      context.Response.Write("0"); 
     } 
    } 
} 

發佈您的代碼,我會看看在它。聽起來就像你指向一個不存在的資源。也許你的'uploader'屬性沒有指向適當的資源,或者你的jquery鏈接被破壞(或不存在)。

+0

優秀,像魅力一樣工作 – 2011-06-24 20:31:56

+3

視頻已被刪除! :( – Dave 2012-05-07 01:11:21

+0

只是提醒說,這個答案中描述的很多參數已經改變了,我建議總是檢查最新的文檔。 – 2013-08-08 14:47:49