Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Changing Image File Names
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Changing Image File Names

 Post Reply Post Reply Page  12>
Author
Misty View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 February 2002
Location: United States
Status: Offline
Points: 711
Post Options Post Options   Thanks (0) Thanks(0)   Quote Misty Quote  Post ReplyReply Direct Link To This Post Topic: Changing Image File Names
    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.

 

 

 

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Misty View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 February 2002
Location: United States
Status: Offline
Points: 711
Post Options Post Options   Thanks (0) Thanks(0)   Quote Misty Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
Misty View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 February 2002
Location: United States
Status: Offline
Points: 711
Post Options Post Options   Thanks (0) Thanks(0)   Quote Misty Quote  Post ReplyReply Direct Link To This Post Posted: 21 August 2003 at 7:52pm
Does anyone here know how to do what I am trying to do?
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Misty View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 February 2002
Location: United States
Status: Offline
Points: 711
Post Options Post Options   Thanks (0) Thanks(0)   Quote Misty Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Misty View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 February 2002
Location: United States
Status: Offline
Points: 711
Post Options Post Options   Thanks (0) Thanks(0)   Quote Misty Quote  Post ReplyReply Direct Link To This Post Posted: 23 August 2003 at 11:22am
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 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.
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.