Hello all,
I can't seem to get my file uploader to rename the file before uploading to the directory.
Here is the code:
$UPLOAD_PATH = "C:/phpdev/www/SWIFTFLIX sell/cover_images/";
$UPLOAD_NUM = 1;
global $UPLOAD_PATH,
$UPLOAD_NUM,
$HTTP_POST_FILES;
$buff = '';
$error = 0;
for ($i = 0; $i < $UPLOAD_NUM; $i++)
{
$name = $HTTP_POST_FILES["File$i"]['name'];
$tmp = $HTTP_POST_FILES["File$i"]['tmp_name'];
$ext = $HTTP_POST_FILES["File$i"]['type'];
if (strstr($ext,"jpeg"))
{
$ext=".jpg";
}
elseif (strstr($ext,"gif"))
{
$ext=".gif";
}
else
{
echo "ERROR: That type of file is not allowed. Only gif/jpeg are allowed.";
echo "<br><a href=\"javascript:void(0);\" onclick=\"history.back(); return(false);\">Back</a>";
exit;
}
$sql_query ="INSERT INTO movie (movie_title, movie_pitch, movie_release_date, movie_duration, movie_classification,
movie_format, movie_sound, movie_studio, movie_status)
VALUES ('$movie_title','$movie_pitch','$movie_release_date','$movie_duration','$movie_classification','$movie_format','$movie_sound',
'$movie_studio','$movie_status')";
$result = mysql_query($sql_query);
$running_id = mysql_insert_id();
$sql_update ="UPDATE movie SET movie_cover_small='$running_id"."_cover_small$ext' WHERE movie_id=$running_id";
$result1 = mysql_query($sql_update);
if (!is_uploaded_file ($tmp))
continue;
$buff .= "$name";
if (!@move_uploaded_file($tmp, $UPLOAD_PATH."/".$name))
$error = 1;
}
Basically i want it renamed to
$running_id"."_cover_small$ext
//this value is what is also inserted into the mySQL DB
Any ideas on how to go about this?
Cheers,
micmac