2

I am trying to upload image file(s) for my project with bootstrap jquery using the HTML5 input type="file" tag in ASP.NET 3.5. I tried so many different methods to do it without using File Upload. However, I couldn't do it with success.

I need your help please. How can I use "input type="file" … " instead of asp:FileUpload

Thanks in advance.

.aspx design page is like this:

<div class="row">
<div class="col-xs-12 col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2">
    <!-- image-preview-filename input [CUT FROM HERE]-->
    <div class="input-group image-preview">
        <input type="text" class="form-control image-preview-filename" disabled="disabled" />
        <!-- don't give a name === doesn't send on POST/GET -->
        <span class="input-group-btn">
            <!-- image-preview-clear button -->
            <button type="button" class="btn btn-default image-preview-clear" style="display:none;">
                <span class="glyphicon glyphicon-remove"></span> Temizle
            </button>                 

            <div class="btn btn-default image-preview-input">
                <span class="glyphicon glyphicon-folder-open"></span><span class="image-preview-input-title">
                    Choose File</span>
                <input type="file" accept="image/png, image/jpeg, image/gif" name="input-file-preview" />
                <!-- rename it -->
            </div>
        </span>
    </div>
    <!-- /input-group image-preview [TO HERE]-->
</div>
/div>

<div class="w3-container w3-padding">
<table width="100%">
<tr>
<td width="16%">
<td width="25%">
<asp:LinkButton ID="resimYukle" runat="server" class="w3-btn w3-theme" 
    onclick="resimYukle_Click">
<span aria-hidden="true" class="fa fa-pencil"></span> Save</asp:LinkButton>
<td width="59%">    
                        </td>        
</td></td></tr></table>

</div>

Screenshot is like this:

Uploading Page Screenshot

1 Answer 1

1

There are two ways to get file name in server side you can use asp controls or you can use bootstrap controls and use runat="server" e.g

   <input type="file" id="filebtn" accept="image/png, image/jpeg, image/gif" runat="server" name="input-file-preview" />

and in cs file use properties as

 var name= filebtn.PostedFile.FileName;

or InputStream or SaveAs

and in asp you can use asp controls but apply css class

 <asp:FileUpload ID="fileupload" CssClass="applyclass" runat="server" />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.