Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I use this javascript <a href="https://github.com/valums/file-uploader" rel="nofollow">tool</a></p> <p>This is the controller (I double check cause IE has a strange behavior) :</p> <pre><code>&lt;HttpPost()&gt; _ Function UploadExcelPriceList(ByVal id As String) As System.String Dim bResult As Boolean = False Dim IsIE As Boolean = False Dim sFileName As String = "" If (Request.Files Is Nothing) OrElse (Request.Files.Count = 0) Then If String.IsNullOrEmpty(Request.Params("qqfile")) Then Return ("{success:false, error:'request file is empty'}") Else sFileName = Request.Params("qqfile").ToString End If Else sFileName = Request.Files(0).FileName IsIE = True End If If String.IsNullOrEmpty(sFileName) Then Return ("{success:false, error:'request file is empty'}") End If Dim DocumentName As String = Id &amp; Path.GetExtension(sFileName) If IsIE Then Try Request.Files(0).SaveAs(Path.Combine(My.Settings.TempFolder, DocumentName)) Catch ex As Exception Return ("{success:false, error:'" &amp; ex.Message &amp; "'}") End Try Else Try If (Request.InputStream IsNot Nothing) AndAlso (Request.InputStream.CanRead) AndAlso (Request.InputStream.Length &gt; 0) Then Using fileStream As FileStream = New FileStream(Path.Combine(My.Settings.TempFolder, DocumentName), FileMode.Create) Dim FileBytes(Core.Convert.ToInt32(Request.InputStream.Length)) As Byte Dim bytesRead As Int32 = 0 bytesRead = Request.InputStream.Read(FileBytes, 0, FileBytes.Length) fileStream.Write(FileBytes, 0, bytesRead) fileStream.Flush() fileStream.Close() bytesRead = Nothing End Using End If Catch ex As Exception Return ("{success:false, error:'" &amp; ex.Message &amp; "'}") End Try End If Return ("{success:true, id: '" &amp; Id &amp; "'}") End Function </code></pre> <p>I put this HTML in my View:</p> <pre><code>&lt;div id="PopupExcelUploader" title="Carica Listino Excel"&gt; &lt;div id="uploaderFile"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>and this is the javascript:</p> <pre><code>function CreateFileUploader() { var uploader = new qq.FileUploader({ element: $('#uploaderFile')[0], template: '&lt;div class="qq-uploader"&gt;' + '&lt;div class="qq-upload-drop-area"&gt;&lt;span&gt;Drop files here to upload&lt;/span&gt;&lt;/div&gt;' + '&lt;div class="qq-upload-button ui-button ui-widget ui-corner-all ui-button-text-only ui-state-default"&gt;Seleziona il Listino Excel&lt;/div&gt;' + '&lt;ul class="qq-upload-list"&gt;&lt;/ul&gt;' + '&lt;/div&gt;', hoverClass: 'ui-state-hover', focusClass: 'ui-state-focus', action: UploaderAction, allowedExtensions: ['xls', 'xlsx'], params: { id: ModelId }, onSubmit: function(file, ext) { }, onComplete: function(id, fileName, responseJSON) { if ((responseJSON.success == null) || (responseJSON.success == 'false')) { $.jGrowl("Error!", { theme: 'MessageError', life: 3000 }); } else { documentUploaded = true; $.jGrowl("Document uploaded successfully!", { theme: 'MessageOk', life: 1800 }); window.setTimeout(function() { $("#PopupExcelUploader").dialog('close'); $("#PriceListDynamicGrid").trigger("reloadGrid"); }, 3000); } } }); } </code></pre>
    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