We help IT Professionals succeed at work.

ASPX upload error to godaddy shared server

cbrick04
cbrick04 asked
on
1,401 Views
Last Modified: 2008-01-09
I have an aspx page with c# code behind, on the page I have a place where users can upload photos using this code in my .cs file:

// Send Upload
         {
            string strFileName;
            {
                UploadConfirmationTextBox.Text = "";
                strFileName = FileUpload.PostedFile.FileName;
                strFileName = strFileName.Substring(strFileName.LastIndexOf("\\") + 1);
                try
                {
                    FileUpload.PostedFile.SaveAs(HttpContext.Current.Request.PhysicalApplicationPath.ToString() +"\\Upload\\UploadedPics\\Origionals\\" + PictureNumberString);
                   
                    UploadConfirmationTextBox.Text = "Uploaded successfully: " + strFileName;
                }
                catch (Exception)
                {
                    UploadConfirmationTextBox.Text = "Error Uploading " + strFileName;
                   
                }
            }
        }

It works on my local machine just fine, but the site is on a godaddy shared server, I have permissions set to Read,Browse,Web and Write but I get "Error Uploading" when trying to send the file. What can I do?
Comment
Watch Question

Jai STech Arch

Commented:
check whether this path exists in the server ...where you are trying to save teh file.,,,

\\Upload\\UploadedPics\\Origionals\\"
Hi there modify your catch statement

                catch (Exception e)
                {
                    UploadConfirmationTextBox.Text = e.Message;
                   
                }

That will provide more information on the actual error.

It may be that the server is not configured correctly. Try a very small file, they may have an upload size limit set.

Commented:
Hi,
for testing change the catch block like this
catch (Exception ex)
                {
                    UploadConfirmationTextBox.Text = "Error Uploading " + strFileName + " because of " + ex.Message
                   
                }

this will give you the exact error message which will help in identifying a solution.
let me know what is the message that you are getting after you modify the catch block.

regards,
Venki

Author

Commented:
This is the error message i get:
Error Uploading CesarChavez.jpg because of Could not find a part of the path 'd:\hosting\JackMan\WebsiteFolder\Upload\UploadedPics\Origionals\2617.JPG'.CesarChavez.jpg
you have 2 file names in that path 2617.JPG and.CesarChavez.jpg

I would say that the last file name should not be there

If this is just a typo, make sure that this path does exist on the server
Basically what you have there is not a valid path, there is a filename outside the quotes.

Is this the folder that you were expecting to upload to, if not, you may have to set the permissions on this folder too.
CERTIFIED EXPERT

Commented:
just like jaiganeshsrinivasan said, check the path and see if it exists on Godaddy or not
You can something like this
string sPath=HttpContext.Current.Request.PhysicalApplicationPath.ToString()) +"\\Upload\\UploadedPics\\Origionals\\";
if (System.IO.Directory.Exists(sPath))
            Response.Write("Path exists");
else

Response.Write("Path do not exists");

you can do this on a test page or before you attempt to upload any files

Author

Commented:
I changed the path to the root folder and I get this error:

Error Uploading CesarChavez.jpg because of Access to the path 'd:\hosting\JackMan\WebsiteFolder\2623.JPG' is denied.CesarChavez.jpg
CERTIFIED EXPERT

Commented:
see the path d:\hosting\JackMan\WebsiteFolder\2623.JPG <<-----2623.JPG--->> This is not a valid path, you have an image here
your path should be d:\hosting\JackMan\WebsiteFolder\\
Nothing after it

Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
The access was being denied by because I had to set permissions for each individual folder, got it fixed, thank you all for your help.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.