Advanced Multi Uploader Support Product Page

This topic was archived

Multi uploader writing to a database

Asked 03 Jul 2009 20:45:50
1
has this question
03 Jul 2009 20:45:50 Ian Phillips posted:
The multi uloader all works fine and does resizing etc as expected but I cannot get it to write to my db. My code is below showing the added text field that continas the danamic FileName..

Any ideas anyone...........


<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="Connections/test.asp" -->
<!--#include file="$config.asp" -->
<!--#include file="ScriptLibrary/incSIP2Class.asp" -->
<!--#include file="ScriptLibrary/incPU3Class.asp" -->
<!--#include file="ScriptLibrary/incPU3Utils.asp" -->

<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME")
If (Request.QueryString <> "" Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
If (CStr(Request("MM_insert") = "UploadQueue" Then
If (Not MM_abortEdit) Then
' execute the insert
Dim MM_editCmd

Set MM_editCmd = Server.CreateObject ("ADODB.Command"
MM_editCmd.ActiveConnection = MM_mysql_conn_STRING
MM_editCmd.CommandText = "INSERT INTO glaziers.gallerypictures (photo) VALUES (?)"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 201, 1, 200, Request.Form("fileName") ' adLongVarChar
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
End If
End If
%>

<%
Dim galleryFolder
galleryFolder=(request.QueryString("folder") 'grab the folder location from the querystring

'galleryUploadPath=(galleryUploadPath)&(galleryFolder)


'*** Pure ASP File Upload 3.0.13
' Process form upload1
Dim pau, DMX_uploadAction, UploadRequest, UploadQueryString, pau_thePath, pau_nameConflict, pau_saveWidth, pau_saveHeight
Set pau = new PureUpload
pau.ScriptLibrary = "ScriptLibrary"
pau.ConflictHandling = "over"
pau.StoreType = "file"
pau.ProgressTemplate = "mac_look.htm"
pau.ProgressWidth = 400
pau.ProgressHeight = 100
'pau.UploadFolder = """image""" replaced with line below referring to config file
pau.UploadFolder =(galleryUploadPath)&(galleryFolder)
pau.ProcessUpload
pau.SaveAll
%>
<%
' Smart Image Processor 2.5.2
Dim sip1
Set sip1 = New ImageProcessor
sip1.ScriptFolder = "ScriptLibrary"
sip1.Component = "Auto"
sip1.Source = "upload"
sip1.AutoOrient = false
sip1.KeepMetaData = false
sip1.Matte = "#FFFFFF"
sip1.UploadFields = ""
sip1.GetFiles
While sip1.HasFiles
sip1.LoadFromSource
sip1.Resize (size1), (size1), true 'use variables from config file
'sip1.AddWatermark "cms_images/uploader-watermarks/75-border.gif", "Center-Center", false, "#000000", "50"
sip1.Overwrite = false
sip1.Mask = "##path####name##-s"&(size1)&".jpg" 'use variables from config file
sip1.SaveJPEG 80
sip1.MoveNext
Wend
Set sip1 = Nothing
%>
<%
' Smart Image Processor 2.5.2
Dim sip2
Set sip2 = New ImageProcessor
sip2.ScriptFolder = "ScriptLibrary"
sip2.Component = "Auto"
sip2.Source = "upload"
sip2.AutoOrient = false
sip2.KeepMetaData = false
sip2.Matte = "#FFFFFF"
sip2.UploadFields = ""
sip2.GetFiles
While sip2.HasFiles
sip2.LoadFromSource
sip2.Resize (size2), (size2), true 'use variables from config file
sip2.Overwrite = false
sip2.Mask = "##path####name##-s"&(size2)&".jpg" 'use variables from config file
sip2.SaveJPEG 80
sip2.MoveNext
Wend
Set sip2 = Nothing
%>
<%
' Smart Image Processor 2.5.2
Dim sip3
Set sip3 = New ImageProcessor
sip3.ScriptFolder = "ScriptLibrary"
sip3.Component = "Auto"
sip3.Source = "upload"
sip3.AutoOrient = false
sip3.KeepMetaData = false
sip3.Matte = "#FFFFFF"
sip3.UploadFields = ""
sip3.GetFiles
While sip3.HasFiles
sip3.LoadFromSource
sip3.Resize (size3), (size3), true 'use variables from config file
sip3.Overwrite = false
sip3.Mask = "##path####name##-s"&(size3)&".jpg" 'use variables from config file
sip3.SaveJPEG 80
sip3.MoveNext
Wend
Set sip3 = Nothing
%>
<%
' Smart Image Processor 2.5.2
Dim sip4
Set sip4 = New ImageProcessor
sip4.ScriptFolder = "ScriptLibrary"
sip4.Component = "Auto"
sip4.Source = "upload"
sip4.AutoOrient = false
sip4.KeepMetaData = false
sip4.Matte = "#FFFFFF"
sip4.UploadFields = ""
sip4.GetFiles
While sip4.HasFiles
sip4.LoadFromSource
sip4.Resize (size4), (size4), true 'use variables from config file
sip4.Overwrite = false
sip4.Mask = "##path####name##-s"&(size4)&".jpg" 'use variables from config file
sip4.SaveJPEG 80
sip4.MoveNext
Wend
Set sip4 = Nothing
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Image upload and resize tool</title>
<script type="text/javascript"><%=pau.generateScriptCode()%></script>
<script src="ScriptLibrary/incPU3.js" type="text/javascript"></script>
<link href="cms_css.css" rel="stylesheet" type="text/css" />
</head>


<div align="center">
<form ACTION="<%=MM_editAction%>" name="UploadQueue" id="UploadQueue" method="POST">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,63,0" width="550" height="350" id="upload1" align="middle">
<param name="FlashVars" value="<%=pau.flashvars()%>&formName=UploadQueue" />
<param name="movie" value="uploader/dmxMultiUploader.swf" />
<param name="quality" value="best" />
<param name="wmode" value="transparent" />
<embed src="uploader/dmxMultiUploader.swf" name="upload1" quality="best" flashvars="<%=pau.flashvars()%>&formName=UploadQueue" wmode="transparent" type="application/x-shockwave-flash" width="550" height="350" pluginspage="www.macromedia.com/go/getflashplayer" />
</object>
<input type="hidden" name="Filedata" />
<script type="text/javascript">window.upload1 = document.forms["UploadQueue"].upload1;</script>
<input type="hidden" name="MM_insert" value="UploadQueue" />
<input type="text" name="fileName" id="fileName" value="<%=pau.Fields("Filedata".fileName %>" />
</form>
<p><a href="javascript:history.go(-1)">Go back to the gallery</a><br />
The uploaded images are in the <strong>image/gallery_images/<%=(galleryFolder)%></strong>.</p>
<p>Uploaded images will be converted to various sizes: <%="("&(size1)&" "&"("&(size2)&" "&"("&(size3)&" "&"("&(size4)&""%></p>
</div>



</body>
</html>

Replies

Replied 03 Jul 2009 23:31:53
03 Jul 2009 23:31:53 Ian Phillips replied:
To add to my case I have just put the insert script and same fields with some static content in the text field and run the insert and it worked.

I thn put it back into my multi image uploader page and the uploader works, converts sizes but does not insert the db
Replied 04 Jul 2009 17:57:28
04 Jul 2009 17:57:28 Patrick Julicher replied:
Hi Ian,

Did you manage to get it working seeing the code from the page I sent you?

Kind regards, Patrick
Replied 04 Jul 2009 18:38:32
04 Jul 2009 18:38:32 Ian Phillips replied:
Still not working. I have you an email back with my code in it and am pasting it in here for all to see.

The upload and resize works fine but no insert into my mysql db

Any of the forum administrators or site developers seen this yet please




<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="Connections/mysql_conn.asp" -->
<!--#include file="$config.asp" -->




<%
Dim galleryFolder
galleryFolder=(request.QueryString("folder") 'grab the folder location from the querystring

'galleryUploadPath=(galleryUploadPath)&(galleryFolder)


'*** Pure ASP File Upload 3.0.13
' Process form upload1
Dim pau, DMX_uploadAction, UploadRequest, UploadQueryString, pau_thePath, pau_nameConflict, pau_saveWidth, pau_saveHeight
Set pau = new PureUpload
pau.ScriptLibrary = "ScriptLibrary"
pau.ConflictHandling = "over"
pau.StoreType = "file"
pau.ProgressTemplate = "mac_look.htm"
pau.ProgressWidth = 400
pau.ProgressHeight = 100
'pau.UploadFolder = """image""" replaced with line below referring to config file
pau.UploadFolder =(galleryUploadPath)&(galleryFolder)
pau.ProcessUpload
pau.SaveAll
%>
<script type="text/javascript"><%=pau.generateScriptCode()%></script>
<script src="ScriptLibrary/incPU3.js" type="text/javascript"></script>

<%
' Smart Image Processor 2.5.2
Dim sip1
Set sip1 = New ImageProcessor
sip1.ScriptFolder = "ScriptLibrary"
sip1.Component = "Auto"
sip1.Source = "upload"
sip1.AutoOrient = false
sip1.KeepMetaData = false
sip1.Matte = "#FFFFFF"
sip1.UploadFields = ""
sip1.GetFiles
While sip1.HasFiles
sip1.LoadFromSource
sip1.Resize (size1), (size1), true 'use variables from config file
'sip1.AddWatermark "cms_images/uploader-watermarks/75-border.gif", "Center-Center", false, "#000000", "50"
sip1.Overwrite = false
sip1.Mask = "##path####name##-s"&(size1)&".jpg" 'use variables from config file
sip1.SaveJPEG 80
sip1.MoveNext
Wend
Set sip1 = Nothing
if pau.Done then
SetUploadFormRequest "width",pau.Fields("fileName".Width
pau_saveWidth = "width"

end if
%>
<%
' Smart Image Processor 2.5.2
Dim sip2
Set sip2 = New ImageProcessor
sip2.ScriptFolder = "ScriptLibrary"
sip2.Component = "Auto"
sip2.Source = "upload"
sip2.AutoOrient = false
sip2.KeepMetaData = false
sip2.Matte = "#FFFFFF"
sip2.UploadFields = ""
sip2.GetFiles
While sip2.HasFiles
sip2.LoadFromSource
sip2.Resize (size2), (size2), true 'use variables from config file
sip2.Overwrite = false
sip2.Mask = "##path####name##-s"&(size2)&".jpg" 'use variables from config file
sip2.SaveJPEG 80
sip2.MoveNext
Wend
Set sip2 = Nothing
%>
<%
' Smart Image Processor 2.5.2
Dim sip3
Set sip3 = New ImageProcessor
sip3.ScriptFolder = "ScriptLibrary"
sip3.Component = "Auto"
sip3.Source = "upload"
sip3.AutoOrient = false
sip3.KeepMetaData = false
sip3.Matte = "#FFFFFF"
sip3.UploadFields = ""
sip3.GetFiles
While sip3.HasFiles
sip3.LoadFromSource
sip3.Resize (size3), (size3), true 'use variables from config file
sip3.Overwrite = false
sip3.Mask = "##path####name##-s"&(size3)&".jpg" 'use variables from config file
sip3.SaveJPEG 80
sip3.MoveNext
Wend
Set sip3 = Nothing
%>
<%
' Smart Image Processor 2.5.2
Dim sip4
Set sip4 = New ImageProcessor
sip4.ScriptFolder = "ScriptLibrary"
sip4.Component = "Auto"
sip4.Source = "upload"
sip4.AutoOrient = false
sip4.KeepMetaData = false
sip4.Matte = "#FFFFFF"
sip4.UploadFields = ""
sip4.GetFiles
While sip4.HasFiles
sip4.LoadFromSource
sip4.Resize (size4), (size4), true 'use variables from config file
sip4.Overwrite = false
sip4.Mask = "##path####name##-s"&(size4)&".jpg" 'use variables from config file
sip4.SaveJPEG 80
sip4.MoveNext
Wend
Set sip4 = Nothing
%>








<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME")
If (Request.QueryString <> "" Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
If (CStr(Request("MM_insert") = "UploadQueue" Then
If (Not MM_abortEdit) Then
' execute the insert
Dim MM_editCmd

Set MM_editCmd = Server.CreateObject ("ADODB.Command"
MM_editCmd.ActiveConnection = MM_mysql_conn_STRING
MM_editCmd.CommandText = "INSERT INTO scmg.gallerypictures (galleryPicturesFilename) VALUES (?)"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 201, 1, 100, Request.Form("fileName") ' adLongVarChar
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

' append the query string to the redirect URL
Dim MM_editRedirectUrl
MM_editRedirectUrl = "cms_galleries.asp"
If (Request.QueryString <> "" Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
Response.Redirect(MM_editRedirectUrl)
End If
End If
%>



<!--#include file="ScriptLibrary/incSIP2Class.asp" -->
<!--#include file="ScriptLibrary/incPU3Class.asp" -->
<!--#include file="ScriptLibrary/incPU3Utils.asp" -->


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Image upload and resize tool</title>

<link href="cms_css.css" rel="stylesheet" type="text/css" />
</head>


<div align="center">

<form ACTION="<%=MM_editAction%>" name="UploadQueue" id="UploadQueue" method="POST">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,63,0" width="550" height="350" id="upload1" align="middle">
<param name="FlashVars" value="<%=pau.flashvars()%>&formName=UploadQueue" />
<param name="movie" value="uploader/dmxMultiUploader.swf" />
<param name="quality" value="best" />
<param name="wmode" value="transparent" />
<embed src="uploader/dmxMultiUploader.swf" name="upload1" quality="best" flashvars="<%=pau.flashvars()%>&formName=UploadQueue" wmode="transparent" type="application/x-shockwave-flash" width="550" height="350" pluginspage="www.macromedia.com/go/getflashplayer" />
</object>
<input type="hidden" name="Filedata" />
<input type="text" name="fileName" value="test insert" />
<script type="text/javascript">window.upload1 = document.forms["UploadQueue"].upload1;</script>
<input type="hidden" name="MM_insert" value="UploadQueue" />
</form>

<p><a href="javascript:history.go(-1)">Go back to the gallery</a><br />
The uploaded images are in the <strong>image/gallery_images/<%=(galleryFolder)%></strong>.</p>
<p>Uploaded images will be converted to various sizes: <%="("&(size1)&" "&"("&(size2)&" "&"("&(size3)&" "&"("&(size4)&""%></p>
</div>



</body>
</html>

Replied 05 Jul 2009 10:10:53
05 Jul 2009 10:10:53 Patrick Julicher replied:
Hi Ian,

I have send you back a copy of your code with some slight modifications. Could you try if that works?

Kind regards, Patrick
Replied 06 Jul 2009 16:01:48
06 Jul 2009 16:01:48 Patrick Julicher replied:
Hi Ian,

As I read in your e-mail, it seems that the modifications have done the trick. Just wanted to post the solution here so others might benefit:

Ian's Upload code looked like this:

If (CStr(Request("MM_insert")) = "UploadQueue") Then
  If (Not MM_abortEdit) Then
    ' execute the insert
    Dim MM_editCmd

    Set MM_editCmd = Server.CreateObject ("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_mysql_conn_STRING
    MM_editCmd.CommandText = "INSERT INTO scmg.gallerypictures (galleryPicturesFilename) VALUES (?)" 
    MM_editCmd.Prepared = true
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 201, 1, 100, Request.Form("fileName")) ' adLongVarChar
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close


and I changed it to this:

If (CStr(UploadFormRequest("MM_insert")) = "UploadQueue") Then
  If (Not MM_abortEdit) Then
    ' execute the insert
    Dim MM_editCmd

    Set MM_editCmd = Server.CreateObject ("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_mysql_conn_STRING
    MM_editCmd.CommandText = "INSERT INTO scmg.gallerypictures (galleryPicturesFilename) VALUES (?)" 
    MM_editCmd.Prepared = true
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 201, 1, 100, UploadFormRequest("Filedata")) ' adLongVarChar
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close



Edited by - Patrick Julicher on 07 Jul 2009  13:14:07

Reply to this topic