Skip to main content
Inspiring
December 4, 2006
Answered

Uploading/ Inserting image file URL

  • December 4, 2006
  • 21 replies
  • 1065 views
running on LAMP.

After finding out that it is best to 'store' images as an address url link rather than in binary in the database itself, I have re-configured the filed definition to VARCHAR and entered some test addresses.

The I have put in a 'logos' directory under the root which will hold all the image files themselves.

I have then managed to get the results php pages to take the url address and display it as an image..

Going great so far.... Here's the crunch..

For both insert and update pages, I have used a form file field which browses the location and inserts it into the field - this does return an address into the field but when it submits, it doesn't save the image data. (Everything else does update OK). In fact, it seems to overwrite with a null value.

I have checked the insert and update behaviours but cannot find where I'm going wrong.

Field code:
<input name="LOGO" type="file" id="LOGO">

Update/Insert code:
GetSQLValueString($HTTP_POST_VARS['LOGO'], "text"),
This topic has been closed for replies.
Correct answer Newsgroup_User
On Wed, 6 Dec 2006 17:36:13 +0000 (UTC), "RichardODreamweaver"
<webforumsuser@macromedia.com> wrote:

>OMG - didn't realise - sorry...

No worries.

I have done a demo for you. It mimics (as far as I can) your database
table and I have pre-loaded the form with test data to save a lot of
typing. Use it to upload logos (jpg or gif format) and then view the
inserted records (and logos using the link provided). I have zipped
the two files and my test database table for your perusal. Note that
the form is not validated - it is just for testing purposes and was
quickly done.

I have emailed the link and files to you.

HTH
--
Steve
steve at flyingtigerwebdesign dot com

21 replies

Inspiring
December 7, 2006
On Thu, 7 Dec 2006 09:42:24 +0000 (UTC), "RichardODreamweaver"
<webforumsuser@macromedia.com> wrote:

> I can't thank you enough.

You're welcome!
--
Steve
steve at flyingtigerwebdesign dot com
Inspiring
December 7, 2006
At last - many many thanks

took a while to work out the differences but got there in the end.

Interestingly, the demo page you have works ok but comes up with the following error on submit.

While trying to retrieve the URL: http://www.flyingtiger-dev.com/uploaddemo/insertrecord.php?

The following error was encountered:

Read Error
The system returned:

(104) Connection reset by peerAn error condition occurred while reading data from the network. Please retry your request.

I can't thank you enough.
Newsgroup_UserCorrect answer
Inspiring
December 7, 2006
On Wed, 6 Dec 2006 17:36:13 +0000 (UTC), "RichardODreamweaver"
<webforumsuser@macromedia.com> wrote:

>OMG - didn't realise - sorry...

No worries.

I have done a demo for you. It mimics (as far as I can) your database
table and I have pre-loaded the form with test data to save a lot of
typing. Use it to upload logos (jpg or gif format) and then view the
inserted records (and logos using the link provided). I have zipped
the two files and my test database table for your perusal. Note that
the form is not validated - it is just for testing purposes and was
quickly done.

I have emailed the link and files to you.

HTH
--
Steve
steve at flyingtigerwebdesign dot com
Inspiring
December 6, 2006
OMG - didn't realise - sorry...
Inspiring
December 6, 2006
On Wed, 6 Dec 2006 14:39:20 +0000 (UTC), "RichardODreamweaver"
<webforumsuser@macromedia.com> wrote:

>hmmm.. haven't got anything yet - did you receive it?

Well, I can't see anything obviously wrong except that I think you
should do a search and replace in code view - you need to search for
$HTTP_POST_VARS and replace with $_POST and also search for
$HTTP_SERVER_VARS and replace with $_SERVER

When you use this page (when it is on the server) is the record being
inserted into the database?

You say:

" It works fine now with just one logo but doesn't work with any
others!"

What do you mean? The first time you use the form (with say logo1.jpg)
it inserts the filename in the database but next time (with say
logo2.jpg) it still inserts logo1.jpg ?

Also, now I look again, there is no code to upload the logo to the
server! Did that get left out in the recent editing of the code?
--
Steve
steve at flyingtigerwebdesign dot com
Inspiring
December 6, 2006
quote:

Originally posted by: Newsgroup User

Well, I can't see anything obviously wrong except that I think you
should do a search and replace in code view - you need to search for
$HTTP_POST_VARS and replace with $_POST and also search for
$HTTP_SERVER_VARS and replace with $_SERVER


Done - no change
quote:

Originally posted by: Newsgroup User
When you use this page (when it is on the server) is the record being
inserted into the database?


Yes - MySQL Database "DBCRM1" table "CONTACTS"
quote:

Originally posted by: Newsgroup User
You say:

" It works fine now with just one logo but doesn't work with any
others!"

What do you mean? The first time you use the form (with say logo1.jpg)
it inserts the filename in the database but next time (with say
logo2.jpg) it still inserts logo1.jpg ?


First time, it inserts the file path correctly and, if I select the same file path for a different record, it will attach it but if I select a different filename, it inserts a null value.
quote:

Originally posted by: Newsgroup User
Also, now I look again, there is no code to upload the logo to the
server! Did that get left out in the recent editing of the code?


eerrrmmm... didn't know you could do that! - all I was doing was physically putting all the logos into a logo directory on the server using windows explorer. Then I was trying to attach the file path onto the record... (just because its an intranet server)

It would be a hell of a lot easier to be able to upload the file to the correct directory.


Inspiring
December 6, 2006
On Wed, 6 Dec 2006 14:39:20 +0000 (UTC), "RichardODreamweaver"
<webforumsuser@macromedia.com> wrote:

>hmmm.. haven't got anything yet - did you receive it?

Yeah, I'll get back to you as soon as I can...
--
Steve
steve at flyingtigerwebdesign dot com
Inspiring
December 6, 2006
hmmm.. haven't got anything yet - did you receive it?
Inspiring
December 6, 2006
On Wed, 6 Dec 2006 09:37:25 +0000 (UTC), "RichardODreamweaver"
<webforumsuser@macromedia.com> wrote:

>Sent as requested....

Thanks. I just got in so I'll take a look after I've eaten! :-)
--
Steve
steve at flyingtigerwebdesign dot com
Inspiring
December 6, 2006
Sent as requested....
Inspiring
December 6, 2006
On Tue, 5 Dec 2006 17:39:50 +0000 (UTC), "RichardODreamweaver"
<webforumsuser@macromedia.com> wrote:

>Damn - spoke too soon.
>
> It works fine now with just one logo but doesn't work with any others!
>
> I have checked the logo filenames but still no luck.
>
> Is this because it is remebering the $_Files array? If so, do I need a line
>to clear it before the new line goes in?

Any chance you could email me the whole page? It is hard to know
what's appening with just code snippets.
--
Steve
steve at flyingtigerwebdesign dot com