Skip to main content
Known Participant
February 21, 2007
Question

PHP, INSERT FILNAME FIELD FROM FORM

  • February 21, 2007
  • 3 replies
  • 330 views
I am trying to do a simple insert record into a MySQL database and for the life of me I cannot get the file field
(<input name="photoNAME" type="file" id="photoNAME" />)
to insert into the database. I have three other fields that do insert correctly the only one that won't go in is that field. I can't even get the form field to echo to the screen.

Anyone have any idea why?

Thanks
This topic is closed to new replies. Start a new post to keep the conversation going.

3 replies

Inspiring
February 21, 2007
On Wed, 21 Feb 2007 16:56:48 +0000, David Powers <david@example.com>
wrote:

>As Gary indicates, using type="file" is for file uploads. If all you're
>trying to do is get the name of the file into a database, there's no
>need to upload the file. In fact, it's a total waste of resources.

I was guessing that the next question would be what happened to the
file. ;-)

Gary
Inspiring
February 21, 2007
Gary White wrote:
> On Wed, 21 Feb 2007 13:49:43 +0000 (UTC), "VernMan"
> <webforumsuser@macromedia.com> wrote:
>
>> (<input name="photoNAME" type="file" id="photoNAME" />)


> See http://www.php.net/manual/en/features.file-upload.php

As Gary indicates, using type="file" is for file uploads. If all you're
trying to do is get the name of the file into a database, there's no
need to upload the file. In fact, it's a total waste of resources.

You need to use the PHP file system functions to build a list of the
images in your folder, and use it to populate a drop-down menu of
filenames. I show how to do it in both "Foundation PHP for Dreamweaver
8" and "PHP Solutions", but it's not all that difficult to code yourself
if you use scandir() (PHP 5 only).

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Inspiring
February 21, 2007
On Wed, 21 Feb 2007 13:49:43 +0000 (UTC), "VernMan"
<webforumsuser@macromedia.com> wrote:

>I am trying to do a simple insert record into a MySQL database and for the life
>of me I cannot get the file field
> (<input name="photoNAME" type="file" id="photoNAME" />)
> to insert into the database. I have three other fields that do insert
>correctly the only one that won't go in is that field. I can't even get the
>form field to echo to the screen.


See http://www.php.net/manual/en/features.file-upload.php

Gary