Unable to find the specified file.

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Unable to find the specified file.

Shawn
Hello,

I am trying to impliment the multi file upload control on one of my pages.
I already have a single upload control that works perfectly. Here is my code:

 if (inputFile.HasFile)
        {
            string targetPath = string.Empty;

            // get file name
            string originalFile = Path.GetFileName(inputFile.FileName);

            // get extension
            string ext = Path.GetExtension(inputFile.FileName).ToLower();

            // create a new file name for storage
            string newFile = Core.Config.SessionUserId.ToString() + ext;

            // upload ORIGINAL image to image/userMainImageFull folder.
            targetPath = HttpContext.Current.Server.MapPath(Core.Config.ImageUploadVirtual + "/userMainImageFull/" + newFile);
            inputFile.MoveTo(targetPath, Brettle.Web.NeatUpload.MoveToOptions.Overwrite);

      
        }
The above code works perfectly.


Its very strange that the new page with the mutli control doesnt work for me. I am getting an error that states

"Unable to find the specified file."


Line 139:  targetPath = HttpContext.Current.Server.MapPath(Core.Config.ImageUploadVirtual + "/userMainImageFull/" + newFile);
Line 140: file.MoveTo(targetPath, Brettle.Web.NeatUpload.MoveToOptions.Overwrite);

The path does exist. It is the same for both pages (C:\sites\mysite\imageupload)

When I debug the "targetpath" it is exactly the same for both. The file name is at the end of the target page

for example:


C:\sites\mysite\imageupload\mynewimage.jpg


Can you please offer some advice to me? I'm totally stumped.

Thank you,

--shawn



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unable to find the specified file.

Shawn
I'm so sorry - here is the code for my new Multi File upload page:


CODE BEHIND:

 if (multiFile.Files.Length > 0)
        {
            foreach (UploadedFile file in multiFile.Files)
            {

                string targetPath = string.Empty;

                // get file name
                string originalFile = System.IO.Path.GetFileName(file.FileName);

                // get extension
                string ext = System.IO.Path.GetExtension(file.FileName).ToLower();

                // create a new file name for storage
                string newFile = "test2" + Core.Config.SessionUserId.ToString() + ext;

                // upload ORIGINAL image to image/userMainImageFull folder.
                targetPath = HttpContext.Current.Server.MapPath(Core.Config.ImageUploadVirtual + "/userMainImageFull/" + newFile);
                file.MoveTo(targetPath, Brettle.Web.NeatUpload.MoveToOptions.Overwrite);

}


And here is my control:


  <Upload:MultiFile id="multiFile" runat="server" useFlashIfAvailable="true"/>



As i stated above, this is pretty much copy +paste of my signle file upload, though I changed the file names to reflect the multi file upload control's varible name.


I have a feeling the multi does it a bit differently, and its throwing me off because I dont see any docs for this example.

Thanks again. I really appricate you taking a look!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unable to find the specified file.

Dean Brettle
Administrator
Please post the code which does not work (i.e. the code which uses MultiFile).  Also, what version of NeatUpload are you using?  Does setting useFlashIfAvailable="false" on the MultiFile control eliminate the error?

--Dean
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unable to find the specified file.

Dean Brettle
Administrator
Is there a stack trace associated with the error?

There is a bug in the MultiFile code you posted.  If 2 files are uploaded with the same extension, the second will overwrite the first.  Does fixing that cause a problem? 

Also, does skipping files where file.HasFile==false help?

--Dean
Loading...