2014-02-24 2 views
0

사용자가 div에 파일을 놓고 파일을 업로드하도록 허용하고 현재 진행중인 다음 페이지로 푸시합니다. 또는 가장 바깥 쪽 div를 클릭하고 다음 페이지로 이동하십시오. (현재 일어나고 있지만 파일 선택 대화 상자가 나타나고, 나는 일어나고 싶지 않습니다.)MVC 파일 업로드 또는 탐색

내가 할 수있는 것처럼 보이지만 어떻게해야할지 모르겠다. 현재이 코드가 있습니다

<div class="coloredContentPlain float-left dataSquares" onclick="window.location.href = '@Url.Action("Index", "CreateJob")'" style="cursor: pointer;"> 
    @using (Html.BeginForm("Index", "CreateJob", FormMethod.Post, new { @id = "upldFrm", @enctype = "multipart/form-data" })) 
    { 
     <div class="circle-color circle-color-background-orange" style="margin-left: auto; margin-right: auto; position: static;"> 
      <span class="circle-text" style="font-size: xx-large; font-weight: bold;">+</span> 
     </div> 

     <div class="newJobText">Start New Job</div> 
     <input id="uploadFile" name="uploadFile" class="uploadFile" type="file" autofocus="autofocus" style="position: absolute; top: 0; left: 0; width: 256px; height: 144px;" /> 
     <input id="sumbitBtn" type="submit" value="Upload File" title="UploadFile" style="display: none;" /> 
     <div style="position: absolute; bottom: 10px;">Click or drop file here</div> 
    } 
</div> 

을 그리고 일부 JQuery와 파일을 선택할 때이 버튼을 제출 클릭 백 엔드에 있습니다 :

$(document).ready(function() { 
    // on file selection, click the hidden submit button 
    $('#uploadFile').change(function() { 
     if ($('#uploadFile')[0].files.length > 0) { 
      $("#sumbitBtn").click(); 
     } 
    }); 
}); 

사용자가 DIV에있는 파일을 삭제하면, 모든 것이 잘 작동합니다. 파일이 업로드되고 사용자는 다음 페이지로 푸시됩니다.

사용자가 div를 클릭하면 사용자가 새 페이지로 이동되고 파일 대화 상자가 튀어 나오지만 새 페이지로만 리디렉션되기를 원합니다.

답변

0

내가 틀릴 수도 있지만 div로 둘러싸인 양식이있는 것 같습니다. onclick은 다른 페이지로 리디렉션됩니다.이 페이지는 클릭 할 때 문제가되는 것처럼 보이며 리디렉션됩니다.

+0

리디렉션하고 싶습니다. 파일 선택 대화 상자가 나타나지 않게하고 싶습니다. 대화 상자가 나타나지 않게하는 방법을 알고 싶습니다. – Sabe