Note that there are some explanatory texts on larger screens.

plurals
  1. POfileUpload in asp.net MVC3.0
    primarykey
    data
    text
    <p>I want to use fileUpload in my MVC view which is an .aspx page. I want to fetch the path into an object in my Controller.</p> <pre><code>&lt;% using (Html.BeginForm("AddClient","Client",FormMethod.Post,new {enctype ="multipart/form-data" })) { %&gt; &lt;div class="float-left"&gt; &lt;%: Html.Label("BAAFile Path") %&gt; &lt;br /&gt; &lt;input type="file" name="file" id="file" /&gt; &lt;%: Html.ValidationMessageFor(model =&gt; model.BAAFilePath) %&gt;--%&gt; &lt;/div&gt; &lt;% } %&gt; </code></pre> <p>at the bottom of the page there is a button to Save details(no button beside fileupload control).</p> <p>Now i want to fetch the path of fileupload control in to my controller.</p> <pre><code> [HttpPost] [ButtonName(Name = "Save")] public ActionResult AddClient(ClientService.ClientDto client,HttpPostedFileBase file) { if (file != null &amp;&amp; file.ContentLength &gt; 0) { // extract only the fielname var fileName = Path.GetFileName(file.FileName); } } </code></pre> <p>now i want to fetch the filepath </p> <pre><code> var fileName = Path.GetFileName(file.FileName); </code></pre> <p>into object of "ClientService.ClientDto" which is "client".</p> <pre><code> client.BAAFilePath=fileName </code></pre> <p>but iam getting null data into "var fileName".</p> <p>iam using following code in "ActionResult AddClient(ClientService.ClientDto client)"</p> <pre><code>if (file != null &amp;&amp; file.ContentLength &gt; 0) { // extract only the fielname var fileName = Path.GetFileName(file.FileName); } </code></pre> <p>am i missing anything?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload