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
651 views
in Technique[技术] by (71.8m points)

multiple upload images on c#/jquery

is there out there any multiple upload images easy to users to upload images like the activex file uploader on facebook.

but free :)

i update my questions i saw that everyone recommend about the flash uploader. i have the problem that i"m using sessions, i"m passing the user album id for relation to the image that been uploaded and the user id that uploded the image

this is the code in the first page

  <div id="divUploadImage" style="display: none;">
                    <FlashUpload:FlashUpload ID="flashUpload" runat="server" UploadPage="Upload2.axd"
                        OnUploadComplete="UploadComplete()" FileTypeDescription="Images" FileTypes="*.gif; *.png; *.jpg; *.jpeg"
                        UploadFileSizeLimit="3000000" TotalUploadSizeLimit="40000000" />
                    <asp:LinkButton ID="LinkButton1" runat="server"></asp:LinkButton>
                </div>

and the code after upload fire on the second page

public void ProcessRequest(HttpContext context)
        {

  for (int j = 0; j < context.Request.Files.Count; j++)
                {

 HttpPostedFile uploadFile = context.Request.Files[j];
  SaveImages(uploadFile, "", albumid,out returnPhotoId); // my function to save ,albumId is the session
                 }
}

thanks

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

Try using uplodify. It uses flash as well, and I highly recommend it. It is a highly customizeable and free product.

For posting to another page after uploading all files:

Make 3 hidden fields like so:

<asp:HiddenField runat="server" ID="hdf_UserID" name="hdf_UserID"  />
<asp:HiddenField runat="server" ID="hdf_AlbumID" name="hdf_AlbumID" />
<asp:HiddenField runat="server" ID="hdf_ImageFiles" name="hdf_ImageFiles" />

and here is how you set up your button to post to the second page:

<asp:Button runat="server" ID="btn_Submit" PostBackUrl="YourPage.aspx" />

Once on the second page you can grab the information out of the request like so:

Request["hdf_UserID"].ToString()
Request["hdf_AlbumID"].ToString()
Request["hdf_ImageFiles"].ToString()

you can store all the files in the hidden field and I would recommend | delimited then you can just do a .split on the other page

For the .ahx page of the uploadify uploader:

using the scriptData option you can pass information to the second page.

 var auth = "<% = Request.Cookies[FormsAuthentication.FormsCookieName]==null ? string.Empty : Request.Cookies[FormsAuthentication.FormsCookieName].Value %>"
 var user = $('[id$=hdf_UserID]').val();
 var album = $('[id$=hdf_AlbumID]').val();

 $('[id$=fileInput]').uploadify({
        'uploader': '../Uploadify/uploadify.swf',
        'script': '../Uploadify/Upload2.ashx',
        'scriptData': {'Token': auth, 'User': user, 'Album': album},

in the .ashx of uploadify you can get the scriptData by the following:

string user = context.Request["User"];
string album = context.Request["Album"];

This code is uploadify specific but hopefully it will help you understand yours


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

...