Alright, how in the world can I do this:
uploadforms.php - A form where you simply input a title, choose a file to upload, add a comment for the file, and select a catagory for the file. All of this info is then passed onto upload.php
upload.php - this takes the info from the forms puts it in a database, I know how to get all the text into the database, but how can i store the file location of the file in the DB (the location of the file on the server)? I cannot seem to get this, and I have been at it for weeks....
Database path store.
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Have a set directory where you store uploaded files. When someone uploads a file, move the file to this directory using move_uploaded_file(). If you want to keep the original name (not the best idea due to name collisions) make sure to use basename() on the filename sent as some browsers will submit the full path it had, otherwise use an md5 of a fairly unique value such as that returned by microtime() or some other form of "random" data. Store (in the database) only the filename used. No need to store more information.
so would this work:
??
Code: Select all
$filename = $file['tmp_name']
$path = move_uploaded_file($file['tmp_name'], 'images/' . $filename);
$sql = "insert into user_art
(title, caption, path) values
('$name', '$caption', '$path')";