Skip to content

Commit

Permalink
Warning message is now correctly hidden in IE9
Browse files Browse the repository at this point in the history
Last changes before publishing the article

Signed-off-by: Valerio.Gheri <valerio.gheri@gmail.com>
  • Loading branch information
vgheri committed Feb 25, 2012
1 parent 8517a22 commit 79db008
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 28 deletions.
14 changes: 7 additions & 7 deletions DesktopDragAndDrop/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public ActionResult Index()
return View();
}

public ActionResult About()
{
return View();
}

[HttpPost]
public string Upload()
{
Expand All @@ -24,12 +29,7 @@ public string Upload()
string virtualPath = SaveFile(file);

return virtualPath;
}

public ActionResult About()
{
return View();
}
}

private UploadedFile RetrieveFileFromRequest()
{
Expand All @@ -38,7 +38,7 @@ private UploadedFile RetrieveFileFromRequest()
byte[] fileContents = null;

if (Request.Files.Count > 0)
{ //they're uploading the old way
{ //we are uploading the old way
var file = Request.Files[0];
fileContents = new byte[file.ContentLength];
file.InputStream.Read(fileContents, 0, file.ContentLength);
Expand Down
30 changes: 10 additions & 20 deletions DesktopDragAndDrop/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,15 @@
<tbody>
<tr>
<td id="td-img-preview" class="tableData">
<img id="preview" src="" alt="[ preview will display here ]" />
<img id="preview" src="" alt="preview will display here" />
</td>
<td id="td-file-name" class="tableData"></td>
<td id="td-file-size" class="tableData"></td>
<td id="td-progress-bar" class="tableData">
<div id="progressBarBox" class="progress progress-info progress-striped">
<div class="bar"></div>
</div>
</td>
<!--
<td id="td-upload-button" class="tableData">
<button type="submit" class="btn btn-primary btn-large">Upload</button>
</td>
-->
</tr>
</tbody>
</table>
Expand All @@ -61,7 +56,7 @@
$("#progressBarBox").hide();
$("#files-list-table").hide();
// CFeck if FileAPI and XmlHttpRequest.upload are supported, so that we can hide the old style input method
// Check if FileAPI and XmlHttpRequest.upload are supported, so that we can hide the old style input method
if (window.File && window.FileReader && window.FileList && window.Blob && new XMLHttpRequest().upload) {
$("#fileSelect").hide();
$("#fallback-submit").hide();
Expand All @@ -75,6 +70,7 @@
dropbox.addEventListener("drop", drop, false);
}
else {
$("#multiupload-alert").hide();
$("#dnd-notes").hide();
}
});
Expand Down Expand Up @@ -109,7 +105,7 @@
var files = evt.dataTransfer.files;
var count = files.length;
// Only call the handler if 1 or more files was dropped.
// Only call the handler if 1 file was dropped.
if (count == 1) {
handleFiles(files);
}
Expand All @@ -129,11 +125,10 @@
var reader = new FileReader();
// init the reader event handlers
//reader.onprogress = handleReaderProgress;
//reader.onprogress = handleReaderProgress; Commented out as we don't really need it
reader.onloadend = handleReaderLoadEnd;
// begin the read operation
//reader.readAsArrayBuffer(file);
// begin the read operation
reader.readAsDataURL(file);
this.UploadFile(file);
}
Expand All @@ -147,8 +142,7 @@
function handleReaderProgress(evt) {
if (evt.lengthComputable) {
var loaded = (evt.loaded / evt.total);
var progress = loaded * 100;
//$("#progressbar").progressbar({ value: loaded * 100 });
var progress = loaded * 100;
$(".bar").css("width", progress + "%");
}
}
Expand Down Expand Up @@ -191,15 +185,11 @@
$("#td-file-name").html(link);
}
}
};
//xhr.open("POST", $("#fileUpload").action, true);
};
xhr.open("POST", "/Home/Upload", true);
// Set appropriate headers
// We're going to use these in the UploadFile method
// To determine what is being uploaded.
// Set appropriate headers
xhr.setRequestHeader("Content-Type", "multipart/form-data");
xhr.setRequestHeader("X-File-Name", file.fileName);
xhr.setRequestHeader("X-File-Size", file.fileSize);
Expand Down
2 changes: 1 addition & 1 deletion DesktopDragAndDrop/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="#">Project name</a>
<a class="brand" href="#">HTML5 DnD</a>
<div class="nav-collapse">
<ul class="nav">
<li class="active"><a href="#">Home</a></li>
Expand Down

0 comments on commit 79db008

Please sign in to comment.