ASPX upload error to godaddy shared server

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?
cbrick04Asked:
Who is Participating?
 
RedKelvinConnect With a Mentor Commented:
Also the access denied error is just that, you do not have permissions to write to that folder
0
 
Jai STech ArchCommented:
check whether this path exists in the server ...where you are trying to save teh file.,,,

\\Upload\\UploadedPics\\Origionals\\"
0
 
RedKelvinCommented:
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.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
tovvenkiCommented:
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

0
 
cbrick04Author 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
0
 
RedKelvinCommented:
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
0
 
RedKelvinCommented:
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.
0
 
SammyCommented:
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

0
 
cbrick04Author 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
0
 
SammyCommented:
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

0
 
cbrick04Author 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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.