Print Page | Close Window

Changing Image File Names

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=5158
Printed Date: 31 March 2026 at 11:59am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Changing Image File Names
Posted By: Misty
Subject: Changing Image File Names
Date Posted: 20 August 2003 at 1:04pm

I have a web application where I upload images to the server using ASP SmartUpload. I am able to do this when I add a record. However, I would like to be able to allow users to edit the picture. For example, the person accidentally uploaded the wrong picture for a certain record. I have the code. But the following code: ENCTYPE="multipart/form-data" in the form won't let me pass a hidden value to the next web page. How do I get a hidden value to pass to the next web page? I know how to pass hidden values to the next web page when I don't have to use ENCTYPE="multipart/form-data" I must have the above code in my form in order for the file to upload.

 

 

 




Replies:
Posted By: MorningZ
Date Posted: 20 August 2003 at 1:35pm
ASPSmartUpload will have a way to get the value from other form fields other than the normal "Request.Form" method.... read the documentation for it

-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: Misty
Date Posted: 20 August 2003 at 1:50pm

I already know how to add records and upload a file using ASP SmartUpload. You are right. You don't use Request.Form. You use this: mySmartUpload.Form. I am going to copy and paste some of my code. I have left the code for the database connection and recordset information out. Please see if you can help me with this.

Let me explain the problem. The second page (EditColor2.asp) won't retrieve the hidden value (SpecialID) from the form.

The page with form:

<%

'-----------------------------------------------------------

'

'----------------------------------------------------------

' name: CreateOneRecordRecordset(soughtKeyValue)

'----------------------------------------------------------

Sub CreateOneRecordRecordset(soughtKeyValue)

'Declare constants for a recordset that allows adding records

'You can also just include the file ADOVBS.INC to get these constants

Const adLockOptimistic = 3

Const adOpenDynamic = 2

'Set the connection details

'Build the sql query used to fill the select element

sqlString = "select * from Specials where SpecialsID=" & soughtKeyValue

'Create a recordset

 

End Sub

'----------------------------------------------------------

' name: DrawPage

'----------------------------------------------------------

Sub DrawPage()

'Load recordset field values into local variables

SpecialsName = rs("SpecialsName") & ""

ImageName = rs("ImageName") & ""

%>

<html>

<head>

<title> Editing Pictures for Specials </title>

 

<p>

<P>

<p>

</head>

<body text="#000000" bgcolor="#ffffff" link="#006666" vlink="#999999" alink="#00cc33" background="toptxtr.gif">

<P align=center>

<SCRIPT LANGUAGE=JAVASCRIPT>

<!--

function InputIsValid()

{

//Check for missing file

if (document.frmSpecials.file.value == "")

{

alert("Please include the file.");

document.frmSpecials.file.focus();

return false;

}

//If it made it here, everything looks ok

return true;

}

// -->

</SCRIPT>

<FONT color=midnightblue size=7>Edit Specials</FONT></P>

<table>

<tr>

<td> </td>

</tr>

</table>

<FORM NAME="frmSpecials"

ACTION="EditSpecialsPic.asp" METHOD="post"

onSubmit="return InputIsValid()" ENCTYPE="multipart/form-data">

<TABLE width=400 align=center valign="top" cellpadding=2 cellspacing=0 border=0 bgcolor=#cccccc>

<TR>

<TD align=right><STRONG><font face=arial size=-1>Name</font></STRONG></TD>

<TD><%= SpecialsName %> </TD>

</TR>

<TR>

<TD align=right><STRONG><font face=arial size=-1>&nbsp;</font></STRONG></TD>

<TD align=center><img src=../images/<%= rs("ImageName") %> width=80 height=100 border=0></TD>

</TR>

<TR>

<TD align=right>&nbsp;</TD>

</TR>

<TR> <TD align="right"><STRONG><font face=arial size=-1>Image</font></STRONG></TD>

<TD width="70%"><INPUT TYPE="file" name="file" size="35"></TD></TR>

<tr>

<td align=right>&nbsp;</td>

<td align=middle>

<INPUT

Type=submit

Name=subSubmit Value="Submit">&nbsp;<INPUT id=reset1 name=reset1 style="WIDTH: 74px; HEIGHT: 24px" type=reset value="Clear form">

</td>

</tr></TABLE><!-- Key value to pass along to the next page -->

<!-- Key value to pass along to the next page -->

<input type=hidden name=hidID value=<%= keyValue %> >

</FORM><!-- END OF FORM -->

</body>

</HTML>

<%

End Sub

'------------------------------------------

'END OF PROCEDURES AND START OF MAIN CODE

'------------------------------------------

dim rs

dim sqlString, KeyValue

dim connectionString, databaseName, physicalPath

dim SpecialsName

dim ImageName

'Get incoming key value

KeyValue = request.QueryString("ID")

'Create a one recordset with only the one

'desired record in it

Call CreateOneRecordRecordset(KeyValue)

'Draw the page

Call DrawPage()

'Close the recordset

%>

Next page that edits the image file's name:

<%

Option Explicit

'===================================================================

' name: EditColor2.asp

 

'Procedures:

' CreateOneRecordRecordset(soughtKeyValue)

' UpdateRecord()

' ConvertEmptyToNull(theString)

' DrawPage()

'===================================================================

 

'----------------------------------------------------------

' name: CreateOneRecordRecordset(soughtKeyValue)

'----------------------------------------------------------

Sub CreateOneRecordRecordset(soughtKeyValue)

'Declare constants for a recordset that allows adding records

'You can also just include the file ADOVBS.INC to get these constants

Const adLockOptimistic = 3

Const adOpenDynamic = 2

dim connectionString, databaseName, path

dim sqlString

' Object creation

' ***************

Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")

'Set connection details

'Build the sql query used to fill the select element

sqlString = "select * from Specials where SpecialsID=" & soughtkeyValue

'Create the recordset

set rs = Server.CreateObject("ADODB.Recordset")

rs.Open sqlString, connectionString, adOpenDynamic, adLockOptimistic

 

 

End Sub

'-------------------------------------------------------------

' name: UpdateRecord()

' description: Update the record

' note: This converts all empty strings to Null values

'--------------------------------------------------------------

Sub UpdateRecord()

 

 

' Upload

' ******

mySmartUpload.Upload

' Select each file

' ****************

For each file In mySmartUpload.Files

' Only if the file exist

' **********************

If not file.IsMissing Then

' Add the current file in a DB field

' **********************************

fic="images/" &file.FileName&""

file.SaveAs(fic)

Rs("ImageName") = file.FileName



Posted By: Misty
Date Posted: 21 August 2003 at 7:52pm
Does anyone here know how to do what I am trying to do?


Posted By: MorningZ
Date Posted: 21 August 2003 at 10:45pm

do you have any idea how impossible it is to follow that much code at once?

seriously. read the doc for the component.. it'll tell you exactly how to pass fields from the form to the code on the next page



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: Misty
Date Posted: 23 August 2003 at 11:01am
Yes, it's hard to follow a lot of code. Unfortunately, I have not been able to find anything helpful. I have no problems with uploading a file and adding records to a database at the same time.  But my problem is with editing records and uploading a file. I know that the problem is with ENCTYPE="multipart/form-data". I must have this in order for the file upload to work. It is strange, but the hidden value will not pass to the next web page when I use this. When I remove ENCTYPE="multipart/form-data" from the form, the hidden value will pass to the next web page. Does anyone have any idea another way I can pass the hidden value to the next web page without causing the file upload to not work?


Posted By: MorningZ
Date Posted: 23 August 2003 at 11:05am

again.. you have to read the documentation for SmartUpload and learn how to get the value of the hidden field....

when you switch the form type to the "multipart" it is not longer as easy as saying "Request.Form("whateverthefieldnameis")"

you have to use the methods available from the component to get that value....

its is for sure possible to do if you do a little investigating..... but it seems like that is beyond you at this point



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: Misty
Date Posted: 23 August 2003 at 11:22am
http://www.aspsmart.com/aspSmartUpload/ - http://www.aspsmart.com/aspSmartUpload/  has some good code samples. But I still cannot find anything about what to do about passing a hidden value from a form that contains the http://www.aspsmart.com/aspSmartUpload/ - ENCTYPE="multipart/form-data"  tag. I guess I will have to try to figure this out. If anyone here has ever done this before, please let me know.


Posted By: MorningZ
Date Posted: 23 August 2003 at 11:55am

its this code sample:

The HTML form:
http://www.aspsmart.com/scripts/aspSmartUpload/publigen/content/templates/show.asp?P=351&L=EN - http://www.aspsmart.com/scripts/aspSmartUpload/publigen/content/templates/show.asp?P=351&L=EN

The ASP to process:
http://www.aspsmart.com/scripts/aspSmartUpload/publigen/content/templates/show.asp?P=356&L=EN - http://www.aspsmart.com/scripts/aspSmartUpload/publigen/content/templates/show.asp?P=356&L=EN

So instead of
Request.Form("FieldName")
you'd use
mySmartUpload.Form("FieldName")

it doesn't matter if its a textbox, hidden field, text area, checkbox, or whatever, its all accessed the same



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: Misty
Date Posted: 24 August 2003 at 1:41pm

MorningZ,

Thank you for the help! I just wanted to let you know that I finally figured out how to do this.



Posted By: MorningZ
Date Posted: 24 August 2003 at 4:06pm

i went through all this pain long time ago when messing with uploading in ASP 3.0

its soooooooooo much easier in .NET



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: betto
Date Posted: 24 October 2003 at 10:15am

Hi misty. do you know how to pass form values trough ASP SMARTUPLOAD I was trying with:

Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
mySmartUpload.Upload
Response.Write(mySmartUpload.Form("title").values)
 

but it shows me error.. could  u tell me why??




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net