Click here to Skip to main content
16,015,827 members
Home / Discussions / ASP.NET
   

ASP.NET

 
Questionadd small delete button or image to the options of select Pin
indian14326-May-17 13:51
indian14326-May-17 13:51 
QuestionNeed some help in implementing Partial View Pin
indian14323-May-17 13:44
indian14323-May-17 13:44 
AnswerRe: Need some help in implementing Partial View Pin
jkirkerx24-May-17 12:33
professionaljkirkerx24-May-17 12:33 
GeneralRe: Need some help in implementing Partial View Pin
indian14324-May-17 13:26
indian14324-May-17 13:26 
GeneralRe: Need some help in implementing Partial View Pin
jkirkerx25-May-17 10:08
professionaljkirkerx25-May-17 10:08 
Questioncell_double click even on grid view Pin
Mayank Kumar23-May-17 0:14
Mayank Kumar23-May-17 0:14 
AnswerRe: cell_double click even on grid view Pin
Maciej Los23-May-17 20:19
mveMaciej Los23-May-17 20:19 
QuestionReturn message to user if file already exists Pin
Hamiltonian1322-May-17 10:59
Hamiltonian1322-May-17 10:59 
Hi all,

I am developing an application that allows users to upload/download/delete files. I have it working but I am struggling to add the following function.

Check if the file already exists in the specified folder,

if the file exists already, return a message telling the user to choose another name.

if the file doesn't exist, save the file in the specified folder.


This is my controller code:

public ActionResult UploadFiles(int? id)
       {
           CI cI = db.Database.Find(id);
           foreach (string upload in Request.Files)
           {

               if (Request.Files[upload].FileName != "")

               {
                   string path = Server.MapPath("~/App_Data/uploads/" + id + "/");
                   string filename = Path.GetFileName(Request.Files[upload].FileName);
                   Response.Write(path);

                   Request.Files[upload].SaveAs(Path.Combine(path, filename));

               }
           }

           return View("Upload");
       }


The upload view:

@{
    ViewBag.Title = "Upload";
}

<h2>Upload</h2>
<script src="~/Scripts/jquery-1.11.1.min.js"></script>
<script>
    $(document).ready(function () {
        $('#btnUploadFile').on('click', function () {
            var data = new FormData();
            var files = $("#fileUpload").get(0).files;
            // Add the uploaded image content to the form data collection
            if (files.length > 0) {
                data.append("UploadedImage", files[0]);
            }
            // Make Ajax request with the contentType = false, and procesDate = false
            var ajaxRequest = $.ajax({
                type: "POST",
                url: "",
                contentType: false,
                processData: false,
                data: data
            });

            ajaxRequest.done(function (xhr, textStatus) {
                @ViewBag.Message
            });
        });
    });
</script>
<input type="file" name="FileUpload1" id="fileUpload" /><br />
<input id="btnUploadFile" type="button" value="Upload File" />
@Html.ActionLink("Documents", "Downloads")

AnswerRe: Return message to user if file already exists Pin
F-ES Sitecore22-May-17 22:59
professionalF-ES Sitecore22-May-17 22:59 
GeneralRe: Return message to user if file already exists Pin
Hamiltonian1324-May-17 8:14
Hamiltonian1324-May-17 8:14 
QuestionSingleton Class in Asp.net application Pin
Rafique Abdullah19-May-17 21:54
Rafique Abdullah19-May-17 21:54 
AnswerRe: Singleton Class in Asp.net application Pin
Nathan Minier20-May-17 12:43
professionalNathan Minier20-May-17 12:43 
GeneralRe: Singleton Class in Asp.net application Pin
Rafique Abdullah22-May-17 7:15
Rafique Abdullah22-May-17 7:15 
GeneralRe: Singleton Class in Asp.net application Pin
F-ES Sitecore22-May-17 22:50
professionalF-ES Sitecore22-May-17 22:50 
QuestionHow to populate dropdownlist in the partial view, base upon the selection of another dropdown value in the view, using angular js Pin
Member 1318632317-May-17 20:16
Member 1318632317-May-17 20:16 
QuestionError Pin
Member 1116162516-May-17 20:10
Member 1116162516-May-17 20:10 
AnswerRe: Error Pin
Kornfeld Eliyahu Peter16-May-17 21:27
professionalKornfeld Eliyahu Peter16-May-17 21:27 
AnswerRe: Error Pin
Richard MacCutchan16-May-17 21:36
mveRichard MacCutchan16-May-17 21:36 
AnswerRe: Error PinPopular
F-ES Sitecore16-May-17 22:11
professionalF-ES Sitecore16-May-17 22:11 
SuggestionRe: Error Pin
Richard Deeming17-May-17 1:24
mveRichard Deeming17-May-17 1:24 
QuestionTelerik version upgradation issue in Asp.net Pin
Member 1058746112-May-17 1:28
Member 1058746112-May-17 1:28 
SuggestionRe: Telerik version upgradation issue in Asp.net Pin
Richard Deeming12-May-17 4:08
mveRichard Deeming12-May-17 4:08 
QuestionGetting the Excepption ExceptionType Newtonsoft.Json.JsonSerializationException in my Web API Pin
indian14311-May-17 8:56
indian14311-May-17 8:56 
SuggestionRe: Getting the Excepption ExceptionType Newtonsoft.Json.JsonSerializationException in my Web API Pin
ZurdoDev11-May-17 9:15
professionalZurdoDev11-May-17 9:15 
GeneralRe: Getting the Excepption ExceptionType Newtonsoft.Json.JsonSerializationException in my Web API Pin
indian14311-May-17 11:20
indian14311-May-17 11:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.