ASP Code:
Set objUpload = CreateObject("ABCUpload4.XForm")
If objUpload.Count > 0 Then
objUpload.OverWrite = True
objUpload.MaxUploadSize = 5120000
objUpload.AbsolutePath = True
frmFieldCount = 0
For i = 1 To objUpload.Files.Count
frmFieldCount = frmFieldCount + 1
strName = objUpload.Item("frm_pgpName" & frmFieldCount - 1) : If Not(validChars(strName)) Then strName = ""
strDesc = objUpload.Item("frm_pgpDesc" & frmFieldCount - 1) : If Not(validChars(strDesc)) Then strDesc = ""
intPrivate = objUpload.Item("frm_pgpPrivate" & frmFieldCount - 1) : If Not(validNumber(intPrivate)) Then intPrivate = 0
intOrder = objUpload.Item("frm_pgpOrder" & frmFieldCount - 1) : If Not(validNumber(intOrder)) Then intOrder = 0
Set objFile = objUpload.Files(i)
If objFile.ImageType <> 0 Then
strFileType = objFile.FileType : If Not(validChars(strFileType)) Then strFileType = ""
intWidth = objFile.ImageWidth : If Not(validNumber(intWidth)) Then intWidth = 0
intHeight = objFile.ImageHeight : If Not(validNumber(intHeight)) Then intHeight = 0
intSize = objFile.Length : If Not(validNumber(intSize)) Then intSize = 0
strFileName = objFile.FileName : If Not(validChars(strFileName)) Then strFileName = ""
objFile.Save sitePath & "sitefiles\image\photos\" & strFileName
Call ReSizeImage(strFileName, Session("Site_ThumbWidth"), Session("Site_ThumbHeight"), Session("Site_ThumbRatio"), Session("Site_ThumbOpt"))
Set objDB = CreateObject("o7thWD.DBv2")
objDB.intCommandType = 4
objDB.strConnString = strConnString
objDB.strQry = "spInsertPhotos"
objDB.arrParamValues = Array(intAlbum, strName, strDesc, strFileName, strFileType, intSize, intHeight, intWidth, UserID, intPrivate, intOrder)
objDB.arrParamDataTypes = Array(3, 200, 203, 203, 200, 3, 3, 3, 3, 3, 3)
objDB.ExecuteQry()
Set objDB = Nothing
End If
Set objFile = Nothing
Next : i = Null
Session("msg") = "Photos Uploaded!"
Redirect("/applications/photos/slide1_manage.asp?album=" & intAlbum)
End If
Set objUpload = Nothing
'Render the uploader form
Write("<div id=""frmUploading""></div><div id=""photoUploader"">" & VbCrLf)
Write("<h1>Add Photos</h1>" & VbCrLf)
Write("<div class=""admin_links""><a href=""/applications/photos/slide1_manage.asp?album=" & intAlbum & """>Back To Album</a></div>" & VbCrLf)
Write("<form style=""margin:28px 0 0 0;"" method=""post"" action=""/applications/photos/slide1_manage.asp?album=" & intAlbum & "&action=2"" enctype=""multipart/form-data"">" & VbCrLf)
Write("<table width=""100%"" cellpadding=""2"" cellspacing=""0"">" & VbCrLf)
Write(" <tr>" & VbCrLf)
Write(" <td width=""35%""><strong>Name</strong></td>" & VbCrLf)
Write(" <td width=""65%""><input type=""text"" name=""frm_pgpName0"" id=""frm_pgpName"" maxlength=""50"" /></td>" & VbCrLf)
Write(" </tr>" & VbCrLf)
Write(" <tr>" & VbCrLf)
Write(" <td><strong>Description</strong></td>" & VbCrLf)
Write(" <td><input type=""text"" name=""frm_pgpDesc0"" id=""frm_pgpDesc"" /></td>" & VbCrLf)
Write(" </tr>" & VbCrLf)
Write(" <tr>" & VbCrLf)
Write(" <td><strong>Private Photo?</strong></td>" & VbCrLf)
Write(" <td><strong>No</strong> <input type=""radio"" name=""frm_pgpPrivate0"" id=""frm_pgpPrivate"" value=""0"" checked=""checked"" /> <strong>Yes</strong> <input type=""radio"" name=""frm_pgpPrivate0"" id=""frm_pgpPrivate"" value=""1"" /></td>" & VbCrLf)
Write(" </tr>" & VbCrLf)
Write(" <tr>" & VbCrLf)
Write(" <td><strong>Display Order</strong></td>" & VbCrLf)
Write(" <td><input type=""text"" name=""frm_pgpOrder0"" id=""frm_pgpOrder"" value=""0"" /></td>" & VbCrLf)
Write(" </tr>" & VbCrLf)
Write(" <tr>" & VbCrLf)
Write(" <td><strong><strong>Photo</strong></strong></td>" & VbCrLf)
Write(" <td><input type=""file"" name=""frm_pgpFile"" id=""frm_pgpFile"" /></td>" & VbCrLf)
Write(" </tr>" & VbCrLf)
Write("</table>" & VbCrLf)
Write("<h2>Photos To Upload</h2>" & VbCrLf)
Write("<div id=""files_list""></div>" & VbCrLf)
Write("<div style=""text-align:center;padding:5px;""><input id=""frmSubmit"" type=""submit"" value=""Upload These Files"" onclick=""if(confirm('Please hold while we upload these photos.')){hideForm();};"" /></div>" & VbCrLf)
Write("</form>" & VbCrLf)
Write("<script type=""text/javascript"">" & VbCrLf)
Write(" <!-- Create an instance of the multiSelector class, pass it the output target and the max number of files -->" & VbCrLf)
Write(" var multi_selector = new MultiSelector( document.getElementById( 'files_list' ), 25 );" & VbCrLf)
Write(" <!-- Pass in the file element -->" & VbCrLf)
Write(" multi_selector.addElement( document.getElementById( 'frm_pgpFile' ) );" & VbCrLf)
Write("</script>" & VbCrLf)
Write("</div>" & VbCrLf)
JS Code:
function MultiSelector( list_target, max ){
// Where to write the list
this.list_target = list_target;
// How many elements?
this.count = 0;
// How many elements?
this.id = 0;
// Is there a maximum?
if( max ){
this.max = max;
} else {
this.max = -1;
};
this.addElement = function( element ){
var tmpID = this.id++;
// Make sure it's a file input element
if( element.tagName == 'INPUT' && element.type == 'file' ){
// Element name -- what number am I?
element.name = 'frm_pgpFile' + tmpID;
element.id = 'frm_pgpFile' + tmpID;
// Add reference to this object
element.multi_selector = this;
// What to do when a file is selected
element.onchange = function(){
// New file input
var new_element = document.createElement( 'input' );
new_element.type = 'file';
new_element.name = 'frm_pgpFile' + tmpID;
new_element.id = 'frm_pgpFile' + tmpID;
this.parentNode.insertBefore( new_element, this );
//New name field
var new_name = document.createElement('input');
new_name.type = 'hidden';
new_name.name = 'frm_pgpName' + tmpID;
new_name.id = 'frm_pgpName' + tmpID;
new_name.value = document.getElementById('frm_pgpName').value
this.parentNode.insertBefore( new_name, this );
document.getElementById('frm_pgpName').value = '';
//New description field
var new_desc = document.createElement('input');
new_desc.type = 'hidden';
new_desc.name = 'frm_pgpDesc' + tmpID;
new_desc.id = 'frm_pgpDesc' + tmpID;
new_desc.value = document.getElementById('frm_pgpDesc').value
this.parentNode.insertBefore( new_desc, this );
document.getElementById('frm_pgpDesc').value = '';
//New private field
var new_priv = document.createElement('input');
new_priv.type = 'hidden';
new_priv.name = 'frm_pgpPrivate' + tmpID;
new_priv.id = 'frm_pgpPrivate' + tmpID;
new_priv.value = document.getElementById('frm_pgpPrivate').value
this.parentNode.insertBefore( new_priv, this );
//New order field
var new_order = document.createElement('input');
new_order.type = 'hidden';
new_order.name = 'frm_pgpOrder' + tmpID;
new_order.id = 'frm_pgpOrder' + tmpID;
new_order.value = document.getElementById('frm_pgpOrder').value
this.parentNode.insertBefore( new_order, this );
document.getElementById('frm_pgpOrder').value = 0;
// Apply 'update' to element
this.multi_selector.addElement( new_element );
// Update list
this.multi_selector.addListRow( this );
// Hide this: we can't use display:none because Safari doesn't like it
this.style.position = 'absolute';
this.style.left = '-1000px';
};
// If we've reached maximum number, disable input element
if( this.max != -1 && this.count >= this.max ){
element.disabled = true;
};
// File element counter
this.count++;
// Most recent element
this.current_element = element;
} else {
// This can only be applied to file input elements!
alert( 'Error: not a file input element' );
};
};
this.addListRow = function( element ){
// Row div
var new_row = document.createElement( 'div' );
// Delete button
var new_row_button = document.createElement( 'input' );
new_row_button.type = 'image';
new_row_button.src = '/icons/trash.png';
new_row_button.value = 'Delete';
// References
new_row.element = element;
// Delete function
new_row_button.onclick= function(){
// Remove element from form
this.parentNode.element.parentNode.removeChild( this.parentNode.element );
// Remove this row from the list
this.parentNode.parentNode.removeChild( this.parentNode );
// Decrement counter
this.parentNode.element.multi_selector.count--;
// Re-enable input element (if it's disabled)
this.parentNode.element.multi_selector.current_element.disabled = false;
return false;
};
// Set row value
new_row.innerHTML = element.value;
// Add button
new_row.appendChild( new_row_button );
// Add it to the list
this.list_target.appendChild( new_row );
};
};
function hideForm() {
var frm = document.getElementById("photoUploader");
var frmUploading = document.getElementById("frmUploading");
frm.style.display = "none";
document.getElementById("tmp").style.display = "none";
frmUploading.innerHTML = '<div style="padding:50px;text-align:center;"><p>Please hold while we upload these photos.</p><p><img src="/icons/loading.gif" alt="Uploading..." /></p></div>';
}
ASP Code:
Set objUpload = CreateObject("ABCUpload4.XForm")
If objUpload.Count > 0 Then
objUpload.OverWrite = True
objUpload.MaxUploadSize = 5120000
objUpload.AbsolutePath = True
fc = 0
For Each File In objUpload.Files
If File.ImageType <> 0 Then
fc = fc + 1
strFileType = File.FileType
intWidth = File.ImageWidth
intHeight = File.ImageHeight
intSize = File.Length
strFileName = File.FileName
pgpName = objUpload.Item("frm_pgpName" & fc)
If Left(pgpName, 1) = "," Then pgpName = Right(pgpName, Len(pgpName) - 1)
pgpDesc = objUpload.Item("frm_pgpDesc" & fc)
If Left(pgpDesc, 1) = "," Then pgpDesc = Right(pgpDesc, Len(pgpDesc) - 1)
pgpPrivate = objUpload.Item("frm_pgpPrivate" & fc)
If Left(pgpPrivate, 2) = "0," Then pgpPrivate = Right(pgpPrivate, Len(pgpPrivate) - 2)
pgpOrder = objUpload.Item("frm_pgpOrder" & fc)
If Left(pgpOrder, 2) = "0," Then pgpOrder = Right(pgpOrder, Len(pgpOrder) - 2)
Write("<strong>Image:</strong> " & fc & "<br />")
Write("<strong>Name:</strong> " & pgpName & "<br />")
Write("<strong>Desc:</strong>" & pgpDesc & "<br />")
Write("<strong>Private:</strong> " & pgpPrivate & "<br />")
Write("<strong>Order:</strong> " & pgpOrder & "<br />")
Write("<strong>File Type:</strong> " & strFileType & "<br />")
Write("<strong>Width:</strong> " & intWidth & "<br />")
Write("<strong>Height:</strong> " & intHeight & "<br />")
Write("<strong>Size:</strong> " & intSize & "<br />")
Write("<strong>File Name:</strong> " & strFileName & "<br /><hr />")
'File.Save sitePath & "sitefiles\image\photos\" & strFileName
'Call ReSizeImage(strFileName, Session("Site_ThumbWidth"), Session("Site_ThumbHeight"), Session("Site_ThumbRatio"), Session("Site_ThumbOpt"))
'Set objDB = CreateObject("o7thWD.DBv2")
' objDB.intCommandType = 4
' objDB.strConnString = strConnString
' objDB.strQry = "spInsertPhotos"
' objDB.arrParamValues = Array(intAlbum, strName, strDesc, strFileName, strFileType, intSize, intHeight, intWidth, UserID, intPrivate, intOrder)
' objDB.arrParamDataTypes = Array(3, 200, 203, 203, 200, 3, 3, 3, 3, 3, 3)
' objDB.ExecuteQry()
'Set objDB = Nothing
End If
Next : File = Null
Response.End
'Session("msg") = "Photos Uploaded!"
'Redirect("/applications/photos/slide1_manage.asp?album=" & intAlbum)
End If
Set objUpload = Nothing
'Render the uploader form
Write("<div id=""frmUploading""></div><div id=""photoUploader"">" & VbCrLf)
Write("<h1>Add Photos</h1>" & VbCrLf)
Write("<div class=""admin_links""><a href=""/applications/photos/slide1_manage.asp?album=" & intAlbum & """>Back To Album</a></div>" & VbCrLf)
Write("<form style=""margin:28px 0 0 0;"" method=""post"" action=""/applications/photos/slide1_manage.asp?album=" & intAlbum & "&action=2"" enctype=""multipart/form-data"">" & VbCrLf)
Write("<table width=""100%"" cellpadding=""2"" cellspacing=""0"">" & VbCrLf)
Write(" <tr>" & VbCrLf)
Write(" <td width=""35%""><strong>Name</strong></td>" & VbCrLf)
Write(" <td width=""65%""><input type=""text"" name=""frm_pgpName1"" id=""frm_pgpName"" maxlength=""50"" /></td>" & VbCrLf)
Write(" </tr>" & VbCrLf)
Write(" <tr>" & VbCrLf)
Write(" <td><strong>Description</strong></td>" & VbCrLf)
Write(" <td><input type=""text"" name=""frm_pgpDesc1"" id=""frm_pgpDesc"" /></td>" & VbCrLf)
Write(" </tr>" & VbCrLf)
Write(" <tr>" & VbCrLf)
Write(" <td><strong>Private Photo?</strong></td>" & VbCrLf)
Write(" <td><strong>No</strong> <input type=""radio"" name=""frm_pgpPrivate1"" id=""frm_pgpPrivate"" value=""0"" checked=""checked"" /> <strong>Yes</strong> <input type=""radio"" name=""frm_pgpPrivate1"" id=""frm_pgpPrivate1"" value=""1"" /></td>" & VbCrLf)
Write(" </tr>" & VbCrLf)
Write(" <tr>" & VbCrLf)
Write(" <td><strong>Display Order</strong></td>" & VbCrLf)
Write(" <td><input type=""text"" name=""frm_pgpOrder1"" id=""frm_pgpOrder"" value=""0"" /></td>" & VbCrLf)
Write(" </tr>" & VbCrLf)
Write(" <tr>" & VbCrLf)
Write(" <td><strong><strong>Photo</strong></strong></td>" & VbCrLf)
Write(" <td><input type=""file"" name=""frm_pgpFile1"" id=""frm_pgpFile"" /></td>" & VbCrLf)
Write(" </tr>" & VbCrLf)
Write("</table>" & VbCrLf)
Write("<h2>Photos To Upload</h2>" & VbCrLf)
Write("<div id=""files_list""></div>" & VbCrLf)
Write("<div style=""text-align:center;padding:5px;""><input id=""frmSubmit"" type=""submit"" value=""Upload These Files"" />")' onclick=""if(confirm('Please hold while we upload these photos.')){hideForm();};"" /></div>" & VbCrLf)
Write("</form>" & VbCrLf)
Write("<script type=""text/javascript"">" & VbCrLf)
Write(" <!-- Create an instance of the multiSelector class, pass it the output target and the max number of files -->" & VbCrLf)
Write(" var multi_selector = new MultiSelector( document.getElementById( 'files_list' ), 25 );" & VbCrLf)
Write(" <!-- Pass in the file element -->" & VbCrLf)
Write(" multi_selector.addElement( document.getElementById( 'frm_pgpFile' ) );" & VbCrLf)
Write("</script>" & VbCrLf)
Write("</div>" & VbCrLf)
JS Code:
function MultiSelector( list_target, max ){
// Where to write the list
this.list_target = list_target;
// How many elements?
this.count = 1;
// How many elements?
this.id = 1;
// Is there a maximum?
if( max ){
this.max = max;
} else {
this.max = -1;
};
this.addElement = function( element ){
var tmpID = this.id++;
// Make sure it's a file input element
if( element.tagName == 'INPUT' && element.type == 'file' ){
// Element name -- what number am I?
element.name = 'frm_pgpFile' + tmpID;
element.id = 'frm_pgpFile' + tmpID;
// Add reference to this object
element.multi_selector = this;
// What to do when a file is selected
element.onchange = function(){
// New file input
var new_element = document.createElement( 'input' );
new_element.type = 'file';
new_element.name = 'frm_pgpFile' + tmpID;
new_element.id = 'frm_pgpFile' + tmpID;
this.parentNode.insertBefore( new_element, this );
//New name field
var new_name = document.createElement('input');
new_name.type = 'hidden';
new_name.name = 'frm_pgpName' + tmpID;
new_name.id = 'frm_pgpName' + tmpID;
new_name.value = document.getElementById('frm_pgpName').value
this.parentNode.insertBefore( new_name, this );
document.getElementById('frm_pgpName').value = '';
//New description field
var new_desc = document.createElement('input');
new_desc.type = 'hidden';
new_desc.name = 'frm_pgpDesc' + tmpID;
new_desc.id = 'frm_pgpDesc' + tmpID;
new_desc.value = document.getElementById('frm_pgpDesc').value
this.parentNode.insertBefore( new_desc, this );
document.getElementById('frm_pgpDesc').value = '';
//New private field
var new_priv = document.createElement('input');
new_priv.type = 'hidden';
new_priv.name = 'frm_pgpPrivate' + tmpID;
if (document.getElementById('frm_pgpPrivate').checked) {
new_priv.value = document.getElementById('frm_pgpPrivate').value;
} else {
new_priv.value = document.getElementById('frm_pgpPrivate1').value;
}
this.parentNode.insertBefore( new_priv, this );
//New order field
var new_order = document.createElement('input');
new_order.type = 'hidden';
new_order.name = 'frm_pgpOrder' + tmpID;
new_order.id = 'frm_pgpOrder' + tmpID;
new_order.value = document.getElementById('frm_pgpOrder').value
this.parentNode.insertBefore( new_order, this );
document.getElementById('frm_pgpOrder').value = 0;
// Apply 'update' to element
this.multi_selector.addElement( new_element );
// Update list
this.multi_selector.addListRow( this );
// Hide this: we can't use display:none because Safari doesn't like it
this.style.position = 'absolute';
this.style.left = '-1000px';
};
// If we've reached maximum number, disable input element
if( this.max != -1 && this.count >= this.max ){
element.disabled = true;
};
// File element counter
this.count++;
// Most recent element
this.current_element = element;
} else {
// This can only be applied to file input elements!
alert( 'Error: not a file input element' );
};
};
this.addListRow = function( element ){
// Row div
var new_row = document.createElement( 'div' );
// Delete button
var new_row_button = document.createElement( 'input' );
new_row_button.type = 'image';
new_row_button.src = '/icons/trash.png';
new_row_button.value = 'Delete';
// References
new_row.element = element;
// Delete function
new_row_button.onclick= function(){
// Remove element from form
this.parentNode.element.parentNode.removeChild( this.parentNode.element );
// Remove this row from the list
this.parentNode.parentNode.removeChild( this.parentNode );
// Decrement counter
this.parentNode.element.multi_selector.count--;
// Re-enable input element (if it's disabled)
this.parentNode.element.multi_selector.current_element.disabled = false;
return false;
};
// Set row value
new_row.innerHTML = element.value;
// Add button
new_row.appendChild( new_row_button );
// Add it to the list
this.list_target.appendChild( new_row );
};
};
function hideForm() {
var frm = document.getElementById("photoUploader");
var frmUploading = document.getElementById("frmUploading");
frm.style.display = "none";
document.getElementById("tmp").style.display = "none";
frmUploading.innerHTML = '<div style="padding:50px;text-align:center;"><p>Please hold while we upload these photos.</p><p><img src="/icons/loading.gif" alt="Uploading..." /></p></div>';
}
Have you checked out ASPUpload?
It does what you need plus more.
Pure ASP upload.
And it can be used on any Hosting Service.
Information on it
http://www.motobit.com/help/scptutl/pure-asp-upload.htm
Download the Free Version (Limited to 10mb Upload at a time)
http://www.motobit.com/dlldownload/pure-asp-upload.zip
=========Window XP Testing Server========
If you use your Winxp like I do, to build your scripts first before uploading them to the hosting company.
Then you will need to download this one.
http://www.motobit.com/dlldownload/ScptUtl.exe
It is a .exe ZIP file, It will register 2 .dll files into IIS so that you can use it.
I am not really sure "why" you cannot use the other files without the.dll on XP. just can't, unless I am missing something.
==========================