When you publish a site in Microsoft Azure, the full path of the file is not transferred just the name. And when locally from Visual Studio you start everything up, what could be the problem?

public async Task<ActionResult> Create(TyreEntity tyreEntity, IEnumerable<HttpPostedFileBase> fileUpload) var UrlPhoto = fileupload.FileUpload("tyres", filename, file.FileName, file.ContentType); @using (Html.BeginForm("Create", "TyreEntities", FormMethod.Post, new { enctype = "multipart/form-data" })) <div class="form-group"> <input type="file" name="fileUpload[0]" /><br /> <input type="file" name="fileUpload[1]" /><br /> <input type="file" name="fileUpload[2]" /><br /> <input type="file" name="fileUpload[3]" /><br /> </div> <div class="form-group"> <div class="col-md-offset-2 col-md-10"> <input type="submit" name="Submit" value="Сохранить" id="SubmitMultiply" class="btn btn-default" accept="image/*"/> </div> 

Locally

    2 answers 2

    Browsers do not transfer the full path of the downloaded file to remote servers for security reasons. Because of the way you can pull out personal information (for example, user name).

    It can not be bypassed - and the server should not care what path the file was at the client. The file data must be read not by the path (which is not on the server), but from the InputStream.

    • Then why can the file not be saved? - Anton
    • @Anton it should not be saved. it comes to you in the form of an InputStream stream - and then what you want with it, then do it. You can save to disk (by creating a FileStream with the path you need on the server), you can download to storage (since this is Azure), you can upload it to the database. - PashaPash

    Instead

     using (var fileStream = System.IO.File.OpenRead(PathFile)) { blockBlob.UploadFromStream(fileStream); } 

    It was necessary

     blockBlob.UploadFromStream(file.InputStream); 

    Thanks @PashaPash for the tip