1

I got this simple jquery plugin to upload files.

i can add multiple files, but i cant seem to write a code that saves all the files, only one..

var _thumb = string.Empty;    
if (!string.IsNullOrEmpty(fuUploadThumps.FileName))
            {
                _thumb = fuUploadThumps.FileName;
                fuUploadThumps.SaveAs(Request.PhysicalApplicationPath + @"\img/produkter\" + _imagePath["categoryImagePath"] + "resized/thumbs/" + StripInput(_thumb));
            }

Can anyone help me?

More code

_objAdmin.Name = StripInput(_thumb);
_objAdmin.Connection = Session["imageConnection"].ToString();

_objAdmin.AddThumbs(_objAdmin);

Thats all :=)

1
  • Can you show us any more of the code? Commented Feb 28, 2011 at 20:04

2 Answers 2

2

What I think jnoreiga is trying to tell you, is to request the files like you request the physical applicationpath. Just like so:

var hfc = Request.Files;
for (var i = 0; i < hfc.Count; i++)
{
    var hpf = hfc[i];
    if (hpf.ContentLength > 0)
    {
        var _thumb = hpf.FileName;
        hpf.SaveAs(
            Request.PhysicalApplicationPath + @"\img/produkter\" + _imagePath["categoryImagePath"] + "resized/thumbs/" + StripInput(_thumb)
        );
    }
    else
    {
        return string.Format("Add some data on file number: {0}, please? :-)", i);
    }
}
Sign up to request clarification or add additional context in comments.

1 Comment

I got it working now! I don't know why I didnt think of this.. Thanks!
1

You have to loop though the requests' file array.

foreach (HttpPostedFileBase file in request.Files)
{
    string filename = file.FileName;                        
}

2 Comments

I tryed what u posted Jnoreiga. It comes with an error, saying that it cant resolve symbol "request".
use a capital R in Request. It's the same object you use in your example for Request.PhysicalApplicationPath

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.