c# - Cannot add image asp.net mvc 5 -


i have model of client property — public string photopath {get; set;}.

i'm trying add image in create httppost method:

public actionresult fileupload(httppostedfilebase file, guid id)     {         if (file != null)         {             string pic = system.io.path.getfilename(file.filename);             string path = system.io.path.combine(                                    server.mappath("~/images/profile"), pic);             file.saveas(path);             client client = db.clients.find(id);             if (client == null) return httpnotfound();             client.photopath = path;             viewbag.imagepath = path;         }         return redirecttoaction("create");     } 

there view (with buttons adding):

@using (html.beginform("fileupload", "clientscontroller", formmethod.post,                         new { enctype = "multipart/form-data", id = model.Сlientidentificator }))     {         <label for="file">upload image:</label>         <input type="file" name="file" id="file" style="width: 100%;" />         <input type="submit" value="upload" class="submit" />     } 

but i'm trying upload image there no result (image doesn't upload) or there exception targeted id = model.clientidentificator: http://i.stack.imgur.com/zqa4y.png

as result, i'm want ask universal method upload image client, using controller's method 2 arguments httppostedfile file , guid cliendid or method compatible task.

p.s. i'll extremely thankful p.p.s. sorry english skills :3)


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -