How to save on a relative path?

Asked

Viewed 376 times

0

I have the following method:

private string SubirImagem(string imagemupload, string sequencia, string clifor)
{
    HttpPostedFile imagem = Request.Files[imagemupload];
    string nomeimagem = "";

    if (imagem != null && imagem.ContentLength > 0)
    {
        string extimagem = Path.GetExtension(imagem.FileName).ToLower();
        nomeimagem = clifor + '_' + sequencia + extimagem;
        imagem.SaveAs(Server.MapPath(Path.Combine("/Uploads", (nomeimagem))));
    }

    return nomeimagem;
}

Local this method is working normally, hosted it is showing error stating that I am not allowed to write to folder:

System.Unauthorizedaccessexception: Access to the path "wayserver" httpdocs Uploads 510247_1.png is denied.

I would like to know how do I save on a relative path? Or some other way to do the above method.

  • You need permission to write on this page, that’s all.

  • According to the company hosting the application this permission has already been granted.

  • The Uploads folder actually exists?

  • Where is the application within the presented structure? Loose in httpdocs? Or inside a folder in httpdocs?

  • Yes, there is locally the application works smoothly.

  • Loose in httpdocs root.

  • Shows the folder structure?

  • Most, if not all, of the shared hosting servers set up the read-only folders, usually you should use the control panel or contact support to give write permission to that folder, recommended to remove the permission to run this folder as well.

  • http://imgur.com/md2aMSq

  • Okay, but what’s the print folder?

  • Uploads, that folder that is showing the permission error.

  • The folder you were in at the time of the print is the folder Uploads? So the entire application is inside the Uploads folder? That doesn’t seem to be it.

  • I had not understood your question ,at the time being called the method I in the folder Pages

  • @Leandrogodoyrosa I called the provider and actually they had not given the permission I had requested before, I was sure that the problem was in the code since the permission had already been granted. Thank you so much for generating this doubt again, the application is running hosted now!

  • @LINQ thank you so much for the help! The problem was an operational error in the hosting company, thank you so much for your time!

Show 10 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.