Quote:
|
Originally Posted by Beaver
Perhaps something like that after the if move uploaded file line.
|
if (move_uploaded_file($_FILES['upfile']['tmp_name'], $upload_dir . $_FILES['upfile']['name']))
{
$new_file = substr(sha1(rand(10, time())), 0, 8) . '.' . $file_types[$filetype];
rename($upload_dir . $_FILES['upfile']['name'], $new_file);
$filename=$new_file;
include("connect.php");
$conn = mysql_connect("localhost","$dbuser","$dbpass") or die ("Could not connect to MySQL");
mysql_select_db($db,$conn) or die ("Could not open database");
$query = "INSERT INTO items VALUES('','$fname','$title','$desc','$filename',no w())";
$result=mysql_query($query);
}
Renames if perfectly, but now the file isn't uploading.
If I change to this....
$new_file = substr(sha1(rand(10, time())), 0, 8) . '.' . $file_types[$filetype];
rename($_FILES['upfile']['name'], $new_file);
it will rename the filename put into the db and upload the pic, but the pic in the folder still has the original name.