Click here to Skip to main content
15,906,816 members
Please Sign up or sign in to vote.
2.00/5 (3 votes)
See more:
C#
///............View................// 
@model IEnumerable<httppostedfilebase>
@{
    Layout = "~/Views/Shared/_LayoutMaster.cshtml";
}
<div>
 @using (Html.BeginForm("UploadImage", "Home", FormMethod.Post, new {
                                              enctype = "multipart/form-data" }))
 {
<div style="float:left; width:300px;padding:10px">
                    <input type="file" name="files" id="file" multiple="multiple" /></div>
                <div style="float:left; width:300px;padding:10px">
                  <input type="submit" name="Upload" value="Upload" />
                </div>
   }
</div>










///......HomeContorller action........./// 
public ActionResult UploadImage(IEnumerable<httppostedfilebase> files)
        {           
            Flickr flickrObject = FlickrManager.GetAuthInstance();
            flickrObject.InstanceCacheDisabled = true;           
            try
            {
                if (files != null)
                {
                   foreach (HttpPostedFileBase file in files)
                    {              
                      string photoid = flickrObject.UploadPicture(file.InputStream, name, title, description, tag, false, false, false, ContentType.Photo, SafetyLevel.None,HiddenFromSearch.Visible);                             
                    }          
            return View("Uploader");
        }</httppostedfilebase></httppostedfilebase>
Posted
Updated 2-Mar-14 2:35am
v2
Comments
suzand 2-Mar-14 7:56am    
Image is being uploaded properly. But i don't think how to display uploading information, like
3 of 5 imageName.jpg uploading.......

I've already spend a lot of time for that.

Please help me...........Thanks in advance.

1 solution

For that you have to use Javascript enabled image uploading framework.You can use DropzoneJS.

What is DropzoneJS ?

DropzoneJS is an open source library that provides drag'n'drop file uploads with image previews.

I have written an article about this.Please read it for more info.

DropzoneJS with ASP.net MVC

dropzonejs Home

UPDATE

Please try is as below and let me know if you have any issues.

C#
Dropzone.options.uploadDropzone = {
    paramName: "file1",
    maxFilesize: 200,
    maxThumbnailFilesize: 10,
    success: function(file, response){
      alert('success');
  },
error: function(file, response){
  alert('error');
  },
};
 
Share this answer
 
v3
Comments
suzand 29-Mar-14 6:46am    
Thanks @Sampath Lokuge.
Its really nice one. I'm using Dropzone.js. Multiple file uploading nicely. One thing i need to add that is
when i click on submit button it check Network connectivity if network not available then display alert and stop uploading. If anyone know please tell me what should i do. sample code is more appreciable.
Sampath Lokuge 29-Mar-14 7:24am    
That is the correct behaviour of the Dropzone.js library. If there is no network, then where you upload it?
Dave Kreskowiak 29-Mar-14 10:10am    
Ummm.... That's kind of a stupid thing to check for for a couple of reasons.

If there is no network, you can't get the webpage to use in the first place.

And, checking for a network in no way guarantees that the network will still be there when the file upload starts nor during the upload.

It's pointless to check!
suzand 29-Mar-14 8:14am    
I just want to show an alrt "Network not available" and then redirect to different view.
Sampath Lokuge 29-Mar-14 8:17am    
If you don't have an internet connection, how can you redirect the user into another view ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900