PDA

View Full Version : Conditional Statement for File Upload


DakotaChick
09-01-2006, 06:46 PM
I'm having an issue with a form determining if there is any information in a field of type File. If there is nothing in the field then i need to have the form submit its information to a different page than if it has something to upload.
Here's what I have. The error message it gives me is that the object doesnt support the method "submit" though I use this same method in another page with basicly the same code and it works just fine.


<!-- Conditional Statement -->
<script language="vbscript">
sub updatetype()
dim imgupload
imgupload= "<%=request.form("myFile")%>"
if imgupload <> "" then
update.action="update2b.asp"
else
update.action="update2a.asp"
end if
update.submit
end sub
</script>

<!-- Form Code here -->
<form name="update" method="POST" enctype="multipart/form-data">
<table width="74%" border="0" align="center">
<tr>
<td width="30%"><div align="right" class="style2">Neighborhood:</div></td>
<td width="16%">
<input name="Label" type="text" id="Label" size="15" tabindex="1" value="<%=(Listings.Fields.Item("Label").Value)%>" /> </td>
<td width="21%"><div align="right" class="style2">Full Bathrooms: </div></td>
<td width="33%" valign="middle">
<input name="FullBath" type="text" id="FullBath" size="15" tabindex="4" value="<%=(Listings.Fields.Item("FullBath").Value)%>" /> </td>
</tr>
<tr>
<td><div align="right" class="style2">Address:</div></td>
<td>
<input name="Address" type="text" id="Address" size="15" tabindex="2" value="<%=(Listings.Fields.Item("Address").Value)%>" /> </td>
<td><div align="right" class="style2">Half Bathrooms: </div></td>
<td valign="middle">
<input name="HalfBath" type="text" id="HalfBath" size="15" tabindex="5" value="<%=(Listings.Fields.Item("HalfBath").Value)%>" /> </td>
</tr>
<tr>
<td><div align="right" class="style2">Bedrooms:</div></td>
<td>
<input name="Bedrooms" type="text" id="Bedrooms" size="15" maxlength="2" tabindex="3" value="<%=(Listings.Fields.Item("Bedrooms").Value)%>" /> </td>
<td><div align="right" class="style2">List Price: </div></td>
<td valign="middle">
<input name="ListPrice" type="text" id="ListPrice" size="15" tabindex="6" value="<%=(Listings.Fields.Item("Price").Value)%>" /> </td>
</tr>
<tr >
<td >&nbsp;</td>
<td valign="middle"colspan="3">
<input name="MoreInfoLink" type="hidden" id="MoreInfoLink" size="50" tabindex="8" value="<%=(Listings.Fields.Item("MoreInfoLink").Value)%>" /></td>
</tr>
<tr>
<td align="right" valign="top" class="style2">Image Filename:</TD>
<td align="left" class="style2" colspan="3"><span class="style6">
<input type="file" name="myFile">
<br />
</span><span class="style12"><I>Click "Browse" to select a .jpg, .gif, or .bmp file to upload</I></span></TD>
</tr>
<tr>
<td colspan="4"><div align="center">
<input name="Submit" type="button" value="Update Listing" onclick=updatetype() /></div></td>
</table>
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="MM_recordId" value="<%= Listings.Fields.Item("Label").Value %>">
<input type="hidden" name="MM_recordId" value="<%= Listings.Fields.Item("MoreInfoLink").Value %>">
</form>


Any help would be appreciated. Thanks.

mehere
09-01-2006, 07:34 PM
is there a particular reason you need to go to different pages? i'm just trying to understand.

also, you can't use request.Form in your code when you have multipart/form-data ... you need to use what the upload component calls for.

DakotaChick
09-01-2006, 08:10 PM
is there a particular reason you need to go to different pages? i'm just trying to understand.

also, you can't use request.Form in your code when you have multipart/form-data ... you need to use what the upload component calls for.
mainly i need a way to force the upload to only upload if the user inputs data in the upload field, and still be able to update the rest of the information. the form is an update form for a real estate company. somtimes they may want to update the image shown for the property, but with the current set up they HAVE TO upload an image to make it process. otherwise the upload process page throws errors about no file to upload.

mehere
09-01-2006, 09:32 PM
i currently have a site set up that if they don't upload a file, it still processes the rest of the code ... i guess that's why i asked why you needed two pages. you should be able to process the other stuff if no file is uploaded with it.

DakotaChick
09-02-2006, 07:55 AM
i currently have a site set up that if they don't upload a file, it still processes the rest of the code ... i guess that's why i asked why you needed two pages. you should be able to process the other stuff if no file is uploaded with it.
After a few hours of staring and realiging the ifs i think i figured out what i needed to do with it to make it do it all in one page.