Getting Uploadify Working in C#

后端 未结 1 768
南笙
南笙 2020-12-01 11:22

This seemed like it should be easy, but I have had trouble getting it to work. I don\'t know why it doesn\'t. It is just showing the normal file input.

Is there any

相关标签:
1条回答
  • 2020-12-01 12:02

    This is a video tutorial on how to get started using C# and Webforms, should help you.

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

    Can you post your code though so that I might be able to show you what you are doing wrong?

    Here is the sample code I have for 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" />
    

    Then you want to make a Handler (.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");
            }
        }
    }
    

    Post your code and I will take a look at it. Sounds like you are pointing to a resource that doesn't exist. Maybe your 'uploader' property is not pointed to the proper resource or your jquery link is broken (or not there).

    0 讨论(0)
提交回复
热议问题