'Getting error while adding FileUpload Webservice

I want to create a web service in Asp.Net WebService.asmx to add image, so I added fileUpload

 string uploadImage(FileUpload file_upload_control, int order_id)
    {

        string path = Server.MapPath($"/orders_images/");
        string directory = Path.Combine(path, order_id.ToString());
        Directory.CreateDirectory(directory);
        string file = "";
        if (file_upload_control.HasFile)
        {
            file = System.IO.Path.Combine(directory, file_upload_control.FileName);
            file_upload_control.SaveAs(file);
        }
        string file_name = file_upload_control.FileName;
        return file_name;
    }
    [WebMethod]
    public string add_image(string curomer_name,FileUpload customer_image)
    {
        string str_curomer_name = curomer_name;
        string str_customer_image = uploadImage(customer_image, 10);
        return "ok";
    }

But I get this error

How can I solve that?



Solution 1:[1]

by researching the problem, The web service use a byte datatype to save images or files in physical drive for example the code above

use byte[] file_upload_control instead of FileUpload file_upload_control

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 msalahi