Click here to Skip to main content
15,908,020 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in my case i develop an aspx page to receive a parameter in url this parameter is stringbase64
then i convert the parameter value to array byte[] to save it on the drive

when i run the page local and give it in the url base64 of an image it works well
but when i call it from the server give me error 404 - File or directory not found.


here is the HTML code and C# code



C#
protected void Page_Load(object sender, EventArgs e)
{
    if (Request.QueryString["image"] != null)
    {
        string imagestring = Request.QueryString["image"];
        //LoadImage(imagestring);

        var c = HttpContext.Current;

        string imagepar = c.Request["image"];

        var base64 = c.Request["image"];

        LoadImage(base64);
    }
}

public void LoadImage(string img)
{
    byte[] bytes = Convert.FromBase64String(img.Replace(' ', '+'));

    Random Ran = new Random();
    string AddToName = DateTime.Now.Day.ToString()
                       + DateTime.Now.Month.ToString()
                       + DateTime.Now.Year.ToString() 
                       + Ran.Next(199999);

    try
    {
        System.IO.File.WriteAllBytes(@"F:\940Attached\img" + AddToName + ".jpg", bytes);
    }
    catch (Exception ee) { Response.Write(ee.ToString()); }

}
Posted
Updated 4-Sep-14 15:28pm
v2
Comments
David Lee 145 4-Sep-14 21:14pm    
The problem is not in your code.
Can your phone access the server? I think you need to check the network status of the server or iis setting first.
cigwork 5-Sep-14 0:49am    
Check that the account the IIS/ASP process runs under has access to the F:\ drive. "File / Dir not found" exception is quite common (IME) when a process doesn't have sufficient rights.
Mohammed Elkholy 5-Sep-14 6:27am    
the drive is exist , and when i run the code local it works well

just when i try to call the page with the parameter image value in url i face that error

and the iis works well because i have another pages works well in the same project
Mohammed Elkholy 5-Sep-14 6:29am    
is the problem the parameter is get not post

and how to make that parameter post not get

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