Forums

ASP

This topic is locked

Pulling my hair out.

Posted 22 Dec 2005 04:46:37
1
has voted
22 Dec 2005 04:46:37 Michael Ryan posted:
I'm using Dreamweaver, Pure upload,Access 2003 and an ASP Site.

As some may already know from searching the forum for a fix to my problem which is when i use pure upload to upload a file to a folder and the path to a database everything works great. If a file isn't uploaded then pure asp overrights the default image in access field Leaving you the dreaded red X.

I have search the forum and found some things tried them but still cant get it to work. Please help!

This is the code for my image in the search page.
<img src="<%=(RS_Search.Fields.Item("Pic".Value)%>" name="Photo" width="100" height="110" id="Photo">

my default image is \NoPhoto.jpg

Do i want to handle this on the search page or on the insert to database page.

Thanks in advance I have spent to much time on this problem already.

Replies

Replied 22 Dec 2005 19:47:39
22 Dec 2005 19:47:39 Michael Behan replied:
Set the default value in the database to "/NoPhoto.jpg"

or if this doesnt work (as I think you might be saying in your post) check to see what is being put in the database when no picture is uploaded. Then on the page that is to display the image have the following
<pre id=code><font face=courier size=2 id=code>
&lt;% if (RS_Search.Fields.Item("Pic".Value) = XXX) THEN%&gt;
&lt;img src="/NoPhoto.jpg"&gt;
&lt;% else %&gt;
&lt;img src="&lt;%=(RS_Search.Fields.Item("Pic".Value)%&gt;"&gt;
&lt;% end if %&gt;
</font id=code></pre id=code>
where XXX is the value in the database when no image is uploaded (example "something" OR null OR "" etc.)

having the database default be the path to a 'no-image' image works fine for me though.

Edited by - mbisme on 22 Dec 2005 19:48:35

Edited by - mbisme on 22 Dec 2005 19:49:36
Replied 23 Dec 2005 01:11:46
23 Dec 2005 01:11:46 Michael Ryan replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Set the default value in the database to "/NoPhoto.jpg"

or if this doesnt work (as I think you might be saying in your post) check to see what is being put in the database when no picture is uploaded. Then on the page that is to display the image have the following
<pre id=code><font face=courier size=2 id=code>
&lt;% if (RS_Search.Fields.Item("Pic".Value) = XXX) THEN%&gt;
&lt;img src="/NoPhoto.jpg"&gt;
&lt;% else %&gt;
&lt;img src="&lt;%=(RS_Search.Fields.Item("Pic".Value)%&gt;"&gt;
&lt;% end if %&gt;
</font id=code></pre id=code>
where XXX is the value in the database when no image is uploaded (example "something" OR null OR "" etc.)

having the database default be the path to a 'no-image' image works fine for me though.

Edited by - mbisme on 22 Dec 2005 19:48:35

Edited by - mbisme on 22 Dec 2005 19:49:36
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>






Thanks where in the display page do i want to put this code? And I tryed putting it in and i keep getting this error

Error Type:
Microsoft VBScript compilation (0x800A03F9)
Expected 'Then'
/BOH/TMPak4wrx959.asp, line 363, column 45
if (RS_Search.Fields.Item("Pic".Value) = " " then
--------------------------------------------^
And thoughts.
Replied 23 Dec 2005 02:08:12
23 Dec 2005 02:08:12 Michael Behan replied:
Put it wherever the image should appear.

The error is because you need to have "Then" where you have "then". The "THEN" in my original post was also incorrect (as I'm used to javascript rather than vbscript)
Replied 23 Dec 2005 02:51:37
23 Dec 2005 02:51:37 Michael Ryan replied:
I tried that and still nothing.
Replied 23 Dec 2005 09:46:03
23 Dec 2005 09:46:03 Dave Clarke replied:
I use pure upload and a file is a required field, so if the user doesn't select a file it doesn't write anything to the database. Maybe i'm missing something but i can't see how your default image is getting overwritten.

ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome.
Replied 23 Dec 2005 09:49:40
23 Dec 2005 09:49:40 Michael Ryan replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
I use pure upload and a file is a required field, so if the user doesn't select a file it doesn't write anything to the database. Maybe i'm missing something but i can't see how your default image is getting overwritten.

ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>


I'm not sure but it is for some reason. If i dont' select a file on the upload page and submit it then go into the database and look. The field is bland no default path.
Replied 23 Dec 2005 21:50:16
23 Dec 2005 21:50:16 Dave Clarke replied:
When you applied pure upload on your page did you make sure the "require upload" check box was checked??

ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome.
Replied 23 Dec 2005 23:01:53
23 Dec 2005 23:01:53 Michael Ryan replied:
no i don't want to require one.
Replied 23 Dec 2005 23:41:12
23 Dec 2005 23:41:12 Michael Behan replied:
just noticed (from your error message) that your code is
if (RS_Search.Fields.Item("Pic".Value) = " "

if when you look at the table after no image was uploaded and there is nothing in the image field this would be represented as "" and not " " in your code.

Still can't see why the database default is being ignored though, you should make sure that it is set, just in case you didnt save the table when you put it in (forgetting to save is something that i do a lot!). Im not sure if its the case with Access but maybe you need quotes around the default value if its going into a text type field.
Replied 23 Dec 2005 23:56:59
23 Dec 2005 23:56:59 Michael Ryan replied:
Still nothing! I still keep getting the Expected 'then' error.

The access database has a default pic set in it and it works great if you input into the database directly and enter other information and not a pic.

When you enter other information and not a pic on the website insert page the default pic get erased.

I believe it is because on the form I have 5 other fields and one file field. The insert behavior is set for the file field to write to the pic field in the database. So when the field on the insert page is left blank then blank is writen to the database.

do you know if their is someway in the upload asp page created by the upload behavior where i can put some code to tell it to skip it if it is blank?

I appreciated everyones help. Happy Holidays. <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
Replied 31 Dec 2005 04:57:05
31 Dec 2005 04:57:05 Javier Castro replied:
is the DB field you use to store the filename a required field?
I have a page where user can uplaod files of events and images or pdf's, however, sometimes there is nothiung to up;oad but text so
to avoid problems I use a conditional display to display an image or file, if there is no record then there is no image or file.

hope it helps,

Javier
ps. Happy New year

Reply to this topic