Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
511 views
in Technique[技术] by (71.8m points)

asp.net - Getting Uploadify Working in C#

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 code / examples to get this working. I am getting frustrated...

Thank you all.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...