Forums

This topic is locked

File feild default value.

Posted 06 Jul 2002 03:19:46
1
has voted
06 Jul 2002 03:19:46 Matt Cooper posted:
Okay,

Here is the problem.

I am creating a used car website. In the "Add Vehicle" page I have 2 parts to the form 1) The vehicle information and 2) The file upload feild.

PROBLEM: I don't want to make upload an image an absolute nessesity, but if they do not upload a picture I cannot have the image field = null. (IE broken image link) I have tired to set the Access field default vaule to the /images/noimage.gif and had set the insert behaviour to ignore that field.

This solved the problem if the user does not upload an image. If they do the image path does not get updated. So......

Can anyone think of a possible solution for this dilemma?

I need to record a path in the database one way or another /images/noimage.gif if they don't upload and "uploaded file path" if they do.

I am using Pure ASP Upload and it is working GREAT!

Thanks for the help!

Matt Cooper

Matt Cooper
Plan B Solutiosn

Replies

Replied 06 Jul 2002 03:44:26
06 Jul 2002 03:44:26 aegis kleais replied:
This shouldn't be a problem.

First, you need to change your database so that the image upload field ALLOWS FOR NULL.. It's displaying the information that you should crosscheck the field for a value.

Something like

<%
......
if (rs.Fields.Item("fldImageURL".Value = "" then response.write(""
else response.write("<img src=" & rs.Fields.Item("fldImageURL".Value & ">"
end if
.....
%>

This way if the field = "" (nothing) then it writes nothing in it's place. If it does contain the URL, then it write it in place.

Access returns errors if you don't supply info to a required field, or if you give no info on a field that cannot be NULL, so choose your Access DB settings wisely. Sometimes the problem doesn't lie in the setup, but the output. Lemme know if it works.
Replied 06 Jul 2002 15:37:21
06 Jul 2002 15:37:21 Matt Cooper replied:
Thanks sooo much for your help!!

This is what I think it should be.

Info......
recordset= addvehicle
Image field = file
Access Feild = image1

CODE

<%
if (addvehicle.file.Item("file".Value = "" then response.write(""
else response.write("<img src=" & addvehicle.file.Item("file".Value & ">"
end if
%>

What do you think?

Matt Cooper
Plan B Solutiosn
Replied 06 Jul 2002 23:37:26
06 Jul 2002 23:37:26 aegis kleais replied:
<%
if (addvehicle.Fields.Item("file".Value) = "" then Response.Write(""
else Response.Write("<img SRC=" & (addvehicle.Fields.Item("file".Value) & ">"
end if
%>

That should be the code.

Aegis Kleais
New Media Web Developer
(DWMX : IIS5.1 : SQL2K : WXP : ASP[VB/JS])
Replied 07 Jul 2002 00:07:41
07 Jul 2002 00:07:41 Matt Cooper replied:
Okay,

Thanks great!

Stupid question. Where do I put the code?

Thanks,



Matt Cooper
Plan B Solutions
Replied 07 Jul 2002 22:41:53
07 Jul 2002 22:41:53 Dave Thomas replied:
You put the code where you want the pic to show up.

"Get the kettle on, time for a brew"

Reply to this topic