|
Posted by guywmustang on 12/28/06 03:25
Well, you can setup your database to have it auto-increment an ID
field.
Then just have it use your move_uploaded_file function as you've done.
If that's successful, just do a simple mysql statement:
$query = "INSERT INTO <dbname> ('id','filename') values ( '', $name);
mysql_query($query);
That's about it.
As far as each file having a unique id... not too much way to do it,
other than like adding a number to the end of the filename, or
possibly... creating a text/xml file which stores an id for each file &
then parsing it out into an array. Just use the database for that if
it's really necessary.
On Dec 27, 3:49 pm, angelduran2...@hotmail.com wrote:
> hi i have this code
> foreach ($_FILES["images"]["error"] as $key => $error) {
> if ($error == UPLOAD_ERR_OK) {
> $tmp_name = $_FILES["images"]["tmp_name"][$key];
> $name = $_FILES["images"]["name"][$key];
> move_uploaded_file($tmp_name, "images/$name");
> }
>
> }and i wish to add it a uniqid to every file uploaded leaving intact
> it's original name as well. and i would also need to get the file name
> and add it to my database. just wondering how to do that if any one can
> help.
Navigation:
[Reply to this message]
|