NYCPHP Meetup

NYPHP.org

[nycphp-talk] next challenge

Chris Shiflett shiflett at php.net
Sun May 11 22:00:04 EDT 2003


--- "Joshua S. Freeman" <jfreeman at amnh.org> wrote:
> The problem is, on submit, I need different form values to be
> submitted to different tables in the database. How do I build
> an insert statement like that?

You use more than one insert statement.

> Also... people are supposed to be able to upload an image with
> this project. I think best practices call for storing the image
> in a file and using php to create a link to that image which gets
> stored as a text 'url' in the database associated with the record
> it needs to show up in...

Just write the images to the filesystem somewhere under document root (in an
images directory perhaps), then you can store either the relative or absolute
URL in the database. That makes it very convenient to display the images,
because you simply use the value in the database as the value of the href
attribute of your anchor tag.

> How is *this* accomplished?  *this* being... asking for someone
> to somehow insert the local image path and then, on submit, moving
> the image to the right place on the server and creating the 'url'
> that goes into the database and putting it in the database?

Well, you don't really "create" a URL. When you write a file within document
root, it is available via HTTP. For example, if your document root is
/usr/local/apache/htdocs, and you write a file in
/usr/local/apache/htdocs/images/foo.png, that image is available, and your
relative URL would be /images/foo.png.

As far as the form field you want to use, just try <input type="file">. Then,
check the $_FILE[] array upon submission, and you'll get an idea about what you
need to do. If you need help writing the file, just search the online manual.

Hope that helps.

Chris


> 
> Thanks for any pointers...
> 
> Cheers,
> 
> J.
> 
> 
> 
> 
> --- Unsubscribe at http://nyphp.org/list/ ---
> 
> 
> 
> 
> 




More information about the talk mailing list