I have this script on my site for uploading files, and I cant seem to get renaming it right. This is the code I have, can someone tell me what im doing wrong?
<?php
if (!empty($_FILES)) {
$random_digit = rand(000000000,999999999);
$tempFile = $random_digit . $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_GET['folder'] . '/';
//change the file name now.
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
// Uncomment the following line if you want to make the directory if it doesn't exist
// mkdir(str_replace('//','/',$targetPath), 0755, true);
$ourfile = $_GET['folder'] . '/' . $_FILES['Filedata']['name'];
move_uploaded_file($tempFile,$targetFile);
include('../includes/dbconfig.php');
$username = $_GET['uname'];
$use = mysql_query("SELECT * FROM login WHERE username = '$username' LIMIT 1")or die("Tpc: ".mysql_error());
$them = mysql_fetch_array($use);
$uid = $them['uid'];
mysql_query("INSERT INTO photos (url, uid, edit) VALUES ('$ourfile','$uid', 'no')") or die(mysql_error());
}
echo "1";
?>