Topic: Plupload ASP
Hello,
I try to integrate plupload to a site that uses ASP.
But I realized that plupload uses PHP.
Is it possible to use ASP to plupload?
And if so, someone he already does?
Thank you.
Pages 1
Hello,
I try to integrate plupload to a site that uses ASP.
But I realized that plupload uses PHP.
Is it possible to use ASP to plupload?
And if so, someone he already does?
Thank you.
PHP handler is only an example, one might implement it in any server-side technology, including ASP. Check this thread for examples.
I would like use Classic ASP not ASP.net
You don't have any examples about classic ASP?
Thanks
Hmm... I'm afraid - no. We will be glad to have though ![]()
Hi, Did you ever get this working, I am trying to implement this into an old ASP site using persists ASP upload component serverside but so far I just get "IO error. Error #2032" as an error.
Any word here on an implementation?
I've tried countless times to get Plupload working on classic ASP. No dice.
Poor documentation and a lack of operational transparency means it's near impossible to troubleshoot.
What specifically are the problems with your implementation? The examples that come bundled with plupload all provide a PHP backend implementation. I would think that the natural division between the browser and server would be relatively clear and an ASP implementation would be similar in concept to the sample PHP implementations.
Also here is some sample asp code for uploading to S3, perhaps there are some similarities to what you are trying to do:
I am also trying to implement this in classic asp. I have it working in PHP on another site. I am trying to port over the PHP to ASP. I can get the flash file selector to show up and I can even upload the files. The files are being uploaded but the backend ASP page doesnt process the the binary stream being uploaded. PHP has $_FILES array built in but I know nothing of that in ASP. How is the binary being sent or does anyone know how to save the binary chunks that are coming in??
OK maybe I found the solution with classic ASP.
I can upload multiple images (and resize).
I think is not perfect but is a good start.
what can I do to post the code?
@giannico, just post it here.
I have working code for classic asp. The upload speed is a little slow. I may try to work on an ASP component in C to enable a better way to write to a binary file which would speed things up, but for now if you need this here you go. The back end only saves the files. It does not check for same file names .. It just over writes them. Also I would turn off logging on the the site as it makes an entry for every chunk that is sent so the log files could become HUGE .. I think I will try to work on a multipart upload handler at some point that would stop that as well.
this is the Java script for the upload control
var uploader = new plupload.Uploader({
runtimes: 'flash',
flash_swf_url: 'js/plupload.flash.swf',
browse_button: 'pickfiles',
url: 'upload.asp',
unique_names: false,
multipart: false,
chunk_size: 20000
});and here is the backend vbscript
<%@ Language=VBScript %>
<%
dim vntPostedData,strTargetDir,filename,objFSO
set objFSO = server.CreateObject ("Scripting.FileSystemObject")
strTargetDir = server.MapPath("uploads")&"\"
filename = Request.QueryString("name")
chunk = Request.QueryString("chunk")
chunks = Request.QueryString("chunks")
if chunk = 0 then 'test to see if this chunk is the start of a file
objFSO.CreateTextFile strTargetDir & filename,1
end if
'save contents of binary read to a text file
set file = objFSO.OpenTextFile (strTargetDir & filename,8,false,true)
vntPostedData = Request.BinaryRead(Request.TotalBytes)
file.Write vntPostedData
file.close
if cint(chunk) + 1 = cint(chunks) then 'test to see if this chunk is the end of a file
'save transferd text file to a binary file then remove the BOM from the start of file and save again
set objFSO = server.CreateObject ("Scripting.FileSystemObject")
Set fromStream = CreateObject("ADODB.Stream")
set toStream = CreateObject("ADODB.Stream")
toStream.Charset = "utf-8"
fromStream.Charset = "utf-8"
fromStream.Type = 2 'text
toStream.Type = 1 'binary
'load text file to a stream
fromStream.open
fromStream.Loadfromfile(strTargetDir & filename)
toStream.Open
'copy text file stream to a binary file stream and save
fromStream.copyto (toStream)
fromStream.flush
toStream.savetofile strTargetDir &"1" & filename,2
toStream.flush
fromStream.close
'open the previous binary stream and set the stream position to
'5 which is after the BOM ( byte order mark ) and resave the stream
Set fromStream = CreateObject("ADODB.Stream")
fromStream.Charset = "utf-8"
fromStream.Type = 1 'binary
fromstream.open
fromStream.Loadfromfile(strTargetDir & "1" & filename)
fromStream.position = 5
fromstream.copyto (tostream)
toStream.savetofile strTargetDir & filename,2
toStream.close
fromStream.close
objFSO.deletefile(strTargetDir & "1" & filename)'delete tempfile
end if
%>Last edited by danielcovington (2011-09-12 17:27:13)
I tried with big images and worked very well.
I used the log window to verify the situation during the transfer of bites.
sorry for the italian comment:
plupload.asp (based on a online example):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<meta name="description" content="Multiple file upload utility using Flash, Silverlight, Google Gears, HTML5 or BrowserPlus!"/>
<meta name="keywords" content="upload,multiple,file upload,upload files,file management,google gears,silverlight,flash,html5,browserplus" />
<meta name="author" content="Moxiecode Systems AB" />
<link rel="stylesheet" type="text/css" href="/css/style.css" media="screen" />
<link rel="alternate" type="application/rss+xml" title="Plupload News RSS" href="http://www.plupload.com/forum_news_rss.php" />
<title>Plupload - A tool for uploading files using Flash, Silverlight, Google Gears, HTML5 or Browserplus</title>
<script type="text/javascript" src="js/syntax/shCore.js"></script>
<script type="text/javascript" src="js/syntax/shBrushJScript.js"></script>
<script type="text/javascript" src="js/syntax/shBrushXml.js"></script>
<link type="text/css" rel="stylesheet" href="css/shCore.css"/>
<link type="text/css" rel="stylesheet" href="css/shThemeDefault.css"/>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("jquery", "1.4");
</script>
</head>
<body id="top">
<%
session("part") = 0
%>
<!-- Load the queue CSS -->
<style type="text/css">@import url(css/plupload.queue.css);</style>
<!-- Thirdparty intialization scripts, needed for the Google Gears and BrowserPlus runtimes -->
<script type="text/javascript" src="js/syntax/gears_init.js"></script>
<script type="text/javascript" src="http://bp.yahooapis.com/2.4.21/browserplus-min.js"></script>
<!-- Load plupload and all it's runtimes and finally the jQuery queue widget -->
<script type="text/javascript" src="js/syntax/plupload.full.min.js"></script>
<script type="text/javascript" src="js/syntax/jquery.plupload.queue.min.js"></script>
<script type="text/javascript">
// Convert divs to queue widgets when the DOM is ready
$(function() {
function log() {
var str = "";
plupload.each(arguments, function(arg) {
var row = "";
if (typeof(arg) != "string") {
plupload.each(arg, function(value, key) {
// Convert items in File objects to human readable form
if (arg instanceof plupload.File) {
// Convert status to human readable
switch (value) {
case plupload.QUEUED:
//value = 'accodato';
value = 'queued';
break;
case plupload.UPLOADING:
value = 'uploading';
break;
case plupload.FAILED:
value = 'failed';
break;
case plupload.DONE:
value = 'done';
break;
}
}
if (typeof(value) != "function") {
row += (row ? ', ' : '') + key + '=' + value;
}
});
str += row + " ";
} else {
str += arg + " ";
}
});
$('#log').append(str + "\n");
}
$("#uploader").pluploadQueue({
// General settings
// runtimes : 'flash,gears,flash,silverlight,browserplus,html5',
runtimes : 'flash',
// server side url
url : 'upload.asp',
max_file_size : '10mb',
chunk_size : '10kb',
unique_names : true,
drop_element: 'uploader_container',
// Resize images on clientside if we can
resize : {width : 640, height : 480, quality : 90},
// Specify what files to browse for
filters : [
{title : "Image files", extensions : "jpg,gif,png"},
{title : "Zip files", extensions : "zip"}
],
// Flash settings
flash_swf_url : 'js/syntax/plupload.flash.swf',
// Silverlight settings
// silverlight_xap_url : 'js/syntax/plupload.silverlight.xap',
// PreInit events, bound before any internal events
preinit : {
Init: function(up, info) {
log('[Init]', 'Info:', info, 'Features:', up.features);
},
UploadFile: function(up, file) {
log('[UploadFile]', file);
log('[UploadFile]', file);
// You can override settings before the file is uploaded
// up.settings.url = 'upload.asp?id=' + file.id;
// up.settings.multipart_params = {param1 : 'value1', param2 : 'value2'};
}
},
// Post init events, bound after the internal events
init : {
Refresh: function(up) {
// Called when upload shim is moved
log('[Refresh]');
},
StateChanged: function(up) {
// Called when the state of the queue is changed
log('[StateChanged]', up.state == plupload.STARTED ? "PARTITO" : "STOPPATO");
},
QueueChanged: function(up) {
// Called when the files in queue are changed by adding/removing files
log('[QueueChanged]');
},
UploadProgress: function(up, file) {
// Called while a file is being uploaded
log('[UploadProgress]', 'File:', file, "Total:", up.total);
},
FilesAdded: function(up, files) {
// Callced when files are added to queue
log('[FilesAdded]');
plupload.each(files, function(file) {
log(' File:', file);
});
},
FilesRemoved: function(up, files) {
// Called when files where removed from queue
log('[FilesRemoved]');
plupload.each(files, function(file) {
log(' File:', file);
});
},
FileUploaded: function(up, file, info) {
// Called when a file has finished uploading
log('[FileUploaded] File:', file, "Info:", info);
},
ChunkUploaded: function(up, file, info) {
// Called when a file chunk has finished uploading
log('[ChunkUploaded] File:', file, "Info:", info);
},
Error: function(up, args) {
// Called when a error has occured
log('[error] ', args);
}
}
});
});
</script>
<div id="main">
<div class="center_wrapper">
<div id="main_content">
<h2>Events example</h2>
<form method="post" action="upload.asp" enctype="multipart/form-data">
<p>This example shows you how to bind various events to your plupload instance.</p>
<h3>Log messages</h3>
<textarea id="log" style="width: 100%; height: 150px; font-size: 11px" spellcheck="false" wrap="off"></textarea>
<br style="clear: both" />
<h4>Upload form</h4>
<div id="uploader" style="height: 330px;">
<p>You browser doesn't have Flash, Silverlight, Gears, BrowserPlus or HTML5 support.</p>
</div>
<br style="clear: both" />
</form>
<h2>Source</h2>
<div>Here are the essentials parts needed to convert a element into an upload queue widget.</div>
<pre class="brush: xml">
</pre>
</div>
</div>
</div>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-692197-2']);
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>server side "upload.asp"
<%
' Timeout di massimo tempo di esecuzione = 100 minuti
Server.ScriptTimeout = 6000
'caching'
response.addheader "Cache-Control", "no-store, no-cache, must-revalidate"
response.addheader "Cache-Control", "post-check=0, pre-check=0"
response.addheader "Pragma", "no-cache"
' Recupero il numero di byte ricevuti
ByteRicevuti = Request.TotalBytes
DatiRicevuti = Request.BinaryRead(ByteRicevuti)
For i = 1 To lenB(DatiRicevuti)
FileBinario = FileBinario & chr(ascB(midB(DatiRicevuti,i,1)))
Next
FirmaFile = left(FileBinario,instr(FileBinario,"" & vbCrLf)-1)
ArrPezzi = split(FileBinario,FirmaFile)
for pezzo = 1 to ubound(ArrPezzi)-1
Inizio = instr(ArrPezzi(pezzo),"" & vbCrLf & "" & vbCrLf)
Intestazione = left(ArrPezzi(pezzo),Inizio-1)
Inizio = Inizio + len("" & vbCrLf) + len("" & vbCrLf)
ContenutoFile = mid(ArrPezzi(pezzo),Inizio,len(ArrPezzi(pezzo))-Inizio-1)
next
'stop
if instr(Intestazione,"file") > 0 then
i = InStr(Intestazione, "filename=")
j = InStr(i + 10, Intestazione, chr(34))
NomeUpload = Mid(Intestazione, i + 10, j - i - 10)
i = InStrRev(NomeUpload,"\")
if i <> 0 then
NomeFile = mid(NomeUpload, i + 1)
else
NomeFile = NomeUpload
end if
if NomeFile <> "" then
dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
Upload1 = True
DimensioneFile1 = len(ContenutoFile)
EstensioneFile1 = right(ContenutoFile,3)
NomeFile1 = "uploads\" & NomeFile 'salvo i file nella directory uploads
if left(ContenutoFile,4) = "ÿØÿà" then 'PRIMO SPEZZONE DEL FILE .JPG
Set textStream = FSO.CreateTextFile(server.mappath(NomeFile1), True, False)
else
Set textStream = FSO.OpenTextFile(server.mappath(NomeFile1), 8, True)
end if
textStream.Write ContenutoFile
textStream.Close
Set textStream = Nothing
Set FSO = Nothing
end if
end if
%>I also stumbled upon this QA at StackOverflow: http://stackoverflow.com/questions/4350 -asp-net-c
I tried with big images and worked very well.
I used the log window to verify the situation during the transfer of bites.sorry for the italian comment:
plupload.asp (based on a online example):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <meta name="description" content="Multiple file upload utility using Flash, Silverlight, Google Gears, HTML5 or BrowserPlus!"/> <meta name="keywords" content="upload,multiple,file upload,upload files,file management,google gears,silverlight,flash,html5,browserplus" /> <meta name="author" content="Moxiecode Systems AB" /> <link rel="stylesheet" type="text/css" href="/css/style.css" media="screen" /> <link rel="alternate" type="application/rss+xml" title="Plupload News RSS" href="http://www.plupload.com/forum_news_rss.php" /> <title>Plupload - A tool for uploading files using Flash, Silverlight, Google Gears, HTML5 or Browserplus</title> <script type="text/javascript" src="js/syntax/shCore.js"></script> <script type="text/javascript" src="js/syntax/shBrushJScript.js"></script> <script type="text/javascript" src="js/syntax/shBrushXml.js"></script> <link type="text/css" rel="stylesheet" href="css/shCore.css"/> <link type="text/css" rel="stylesheet" href="css/shThemeDefault.css"/> <script type="text/javascript" src="http://www.google.com/jsapi"></script> <script type="text/javascript"> google.load("jquery", "1.4"); </script> </head> <body id="top"> <% session("part") = 0 %> <!-- Load the queue CSS --> <style type="text/css">@import url(css/plupload.queue.css);</style> <!-- Thirdparty intialization scripts, needed for the Google Gears and BrowserPlus runtimes --> <script type="text/javascript" src="js/syntax/gears_init.js"></script> <script type="text/javascript" src="http://bp.yahooapis.com/2.4.21/browserplus-min.js"></script> <!-- Load plupload and all it's runtimes and finally the jQuery queue widget --> <script type="text/javascript" src="js/syntax/plupload.full.min.js"></script> <script type="text/javascript" src="js/syntax/jquery.plupload.queue.min.js"></script> <script type="text/javascript"> // Convert divs to queue widgets when the DOM is ready $(function() { function log() { var str = ""; plupload.each(arguments, function(arg) { var row = ""; if (typeof(arg) != "string") { plupload.each(arg, function(value, key) { // Convert items in File objects to human readable form if (arg instanceof plupload.File) { // Convert status to human readable switch (value) { case plupload.QUEUED: //value = 'accodato'; value = 'queued'; break; case plupload.UPLOADING: value = 'uploading'; break; case plupload.FAILED: value = 'failed'; break; case plupload.DONE: value = 'done'; break; } } if (typeof(value) != "function") { row += (row ? ', ' : '') + key + '=' + value; } }); str += row + " "; } else { str += arg + " "; } }); $('#log').append(str + "\n"); } $("#uploader").pluploadQueue({ // General settings // runtimes : 'flash,gears,flash,silverlight,browserplus,html5', runtimes : 'flash', // server side url url : 'upload.asp', max_file_size : '10mb', chunk_size : '10kb', unique_names : true, drop_element: 'uploader_container', // Resize images on clientside if we can resize : {width : 640, height : 480, quality : 90}, // Specify what files to browse for filters : [ {title : "Image files", extensions : "jpg,gif,png"}, {title : "Zip files", extensions : "zip"} ], // Flash settings flash_swf_url : 'js/syntax/plupload.flash.swf', // Silverlight settings // silverlight_xap_url : 'js/syntax/plupload.silverlight.xap', // PreInit events, bound before any internal events preinit : { Init: function(up, info) { log('[Init]', 'Info:', info, 'Features:', up.features); }, UploadFile: function(up, file) { log('[UploadFile]', file); log('[UploadFile]', file); // You can override settings before the file is uploaded // up.settings.url = 'upload.asp?id=' + file.id; // up.settings.multipart_params = {param1 : 'value1', param2 : 'value2'}; } }, // Post init events, bound after the internal events init : { Refresh: function(up) { // Called when upload shim is moved log('[Refresh]'); }, StateChanged: function(up) { // Called when the state of the queue is changed log('[StateChanged]', up.state == plupload.STARTED ? "PARTITO" : "STOPPATO"); }, QueueChanged: function(up) { // Called when the files in queue are changed by adding/removing files log('[QueueChanged]'); }, UploadProgress: function(up, file) { // Called while a file is being uploaded log('[UploadProgress]', 'File:', file, "Total:", up.total); }, FilesAdded: function(up, files) { // Callced when files are added to queue log('[FilesAdded]'); plupload.each(files, function(file) { log(' File:', file); }); }, FilesRemoved: function(up, files) { // Called when files where removed from queue log('[FilesRemoved]'); plupload.each(files, function(file) { log(' File:', file); }); }, FileUploaded: function(up, file, info) { // Called when a file has finished uploading log('[FileUploaded] File:', file, "Info:", info); }, ChunkUploaded: function(up, file, info) { // Called when a file chunk has finished uploading log('[ChunkUploaded] File:', file, "Info:", info); }, Error: function(up, args) { // Called when a error has occured log('[error] ', args); } } }); }); </script> <div id="main"> <div class="center_wrapper"> <div id="main_content"> <h2>Events example</h2> <form method="post" action="upload.asp" enctype="multipart/form-data"> <p>This example shows you how to bind various events to your plupload instance.</p> <h3>Log messages</h3> <textarea id="log" style="width: 100%; height: 150px; font-size: 11px" spellcheck="false" wrap="off"></textarea> <br style="clear: both" /> <h4>Upload form</h4> <div id="uploader" style="height: 330px;"> <p>You browser doesn't have Flash, Silverlight, Gears, BrowserPlus or HTML5 support.</p> </div> <br style="clear: both" /> </form> <h2>Source</h2> <div>Here are the essentials parts needed to convert a element into an upload queue widget.</div> <pre class="brush: xml"> </pre> </div> </div> </div> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-692197-2']); _gaq.push(['_setDomainName', 'none']); _gaq.push(['_setAllowLinker', true]); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> </body> </html>server side "upload.asp"
<% ' Timeout di massimo tempo di esecuzione = 100 minuti Server.ScriptTimeout = 6000 'caching' response.addheader "Cache-Control", "no-store, no-cache, must-revalidate" response.addheader "Cache-Control", "post-check=0, pre-check=0" response.addheader "Pragma", "no-cache" ' Recupero il numero di byte ricevuti ByteRicevuti = Request.TotalBytes DatiRicevuti = Request.BinaryRead(ByteRicevuti) For i = 1 To lenB(DatiRicevuti) FileBinario = FileBinario & chr(ascB(midB(DatiRicevuti,i,1))) Next FirmaFile = left(FileBinario,instr(FileBinario,"" & vbCrLf)-1) ArrPezzi = split(FileBinario,FirmaFile) for pezzo = 1 to ubound(ArrPezzi)-1 Inizio = instr(ArrPezzi(pezzo),"" & vbCrLf & "" & vbCrLf) Intestazione = left(ArrPezzi(pezzo),Inizio-1) Inizio = Inizio + len("" & vbCrLf) + len("" & vbCrLf) ContenutoFile = mid(ArrPezzi(pezzo),Inizio,len(ArrPezzi(pezzo))-Inizio-1) next 'stop if instr(Intestazione,"file") > 0 then i = InStr(Intestazione, "filename=") j = InStr(i + 10, Intestazione, chr(34)) NomeUpload = Mid(Intestazione, i + 10, j - i - 10) i = InStrRev(NomeUpload,"\") if i <> 0 then NomeFile = mid(NomeUpload, i + 1) else NomeFile = NomeUpload end if if NomeFile <> "" then dim FSO Set FSO = CreateObject("Scripting.FileSystemObject") Upload1 = True DimensioneFile1 = len(ContenutoFile) EstensioneFile1 = right(ContenutoFile,3) NomeFile1 = "uploads\" & NomeFile 'salvo i file nella directory uploads if left(ContenutoFile,4) = "ÿØÿà" then 'PRIMO SPEZZONE DEL FILE .JPG Set textStream = FSO.CreateTextFile(server.mappath(NomeFile1), True, False) else Set textStream = FSO.OpenTextFile(server.mappath(NomeFile1), 8, True) end if textStream.Write ContenutoFile textStream.Close Set textStream = Nothing Set FSO = Nothing end if end if %>
Thank you very much for your code!! It's great!! I only have one problem... you say it works very well with big images, but in my case, if I upload an imagen with around 1Mb, it goes too slow ![]()
I've probed with "plupload" and "pluploadQueue", but the result is the same.
We are also using plupload with classic asp, but we decided to add a little bit of .net in the middle of our asp application, we have a file called upload.ashx, in the middle of our asp, both work fine together, and it was really easier to get access to the uploaded file that way, by simply using the request.file object collection.
And, asp.net 2.0+ chunk the file in a temporary folder during the upload to not overload the RAM, and it gives you the handler to the complete file while the upload is finished, so you do not have to handle chunks and everything else.
I am trying to integrate plupload to a site that uses ASP.What sample given here I was not able to integrate. Can some provide code
Thanks
Pramod
Pages 1
You are not logged in. Please login or register.