changing file name of uploaded file to mysql record id
Posted on 2004-08-10
is there a way that after i've submitted a file that i could change it to the id of the mysql record which is auto increment.
so if it was for site 23 the header file would be renamed to header23.jpg, the name of the background file would be bg23.jpg and the name of the zipfile of pics would be piczip23.zip instead of the file name which i originally uploaded.
this is the code i have for after submit is clicked on the form.
if($_POST['submit']) //If submit is hit
$dirheader = "headers";
$dirbackground = "backgrounds";
$dirpiczip = "piczips";
$destheader = $dirheader."/".$image_name['header'];
$destbackground = $dirbackground."/".$image_name['background'];
$destpiczip = $dirpiczip."/".$zip_name['photos'];
// upload file set
if(copy($image['header'], $destheader) && copy($image['background'], $destbackground) && copy($zip['photos'], $destpiczip))
echo 'image set has been uploaded <p></p>';
echo 'image set DID NOT upload <p></p>';
$sitename = $_POST['sitename'];
$domain = $_POST['domain'];
$sitepath = $_POST['sitepath'];
$category = $_POST['category'];
$description = $_POST['description'];
$siteurl = $_POST['siteurl'];
$result=MYSQL_QUERY("INSERT INTO sites (id,sitename,domain,sitepath,category,description,header,bg,piczip,siteurl)".
"VALUES ('NULL', '$sitename', '$domain', '$sitepath', '$category', '$description', '$destheader', '$destbackground', '$destpiczip', '$siteurl')");
echo "Query Finished";
thanks for any help