Tech Support Guy banner
Status
Not open for further replies.

timestamp

1K views 0 replies 1 participant last post by  mrsaywho 
#1 ·
Does anyone know how to attach a timestamp to this code so when I upload the 4 images I get a timestamp.jpg? I have managed to have the image file in the folder get timestamped but not the path in mysql.
HTML:
<?php
require_once('storescripts/connect.php');
mysql_select_db($database_phpimage,$phpimage);
$unique = strtolower(substr(md5(time()), 0, 4));	
$uploadDir = 'upload/';

if(isset($_POST['upload' . $config]))
{
foreach ($_FILES as $file)
{

$fileName = $file['name'];
$tmpName = $file['tmp_name'];
$fileSize = $file['size'];
$fileType = $file['type'];

if($fileName==""){

$filePath = 'upload/';
}
else{

$filePath = $uploadDir . $unique . $fileName;
}

$filePath = str_replace(" ", "_", $filePath);
$result = move_uploaded_file($tmpName, $filePath);

if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}
$fileinsert[]=$filePath;
}
}

$mid   = mysql_real_escape_string(trim($_POST['mid']));
$cat   = mysql_real_escape_string(trim($_POST['cat']));
$item  = mysql_real_escape_string(trim($_POST['item']));
$price = mysql_real_escape_string(trim($_POST['price']));
$about = mysql_real_escape_string(trim($_POST['about']));

$fields = array();
$values = array();
$updateVals = array();

for($i=1; $i<=4; $i++)
{
    $fields[$i] = 'name'.$i;
    $values[$i] = mysql_real_escape_string(basename(trim($_FILES[$fields[$i]]['name'])));
    if($values[$i] != '')
    {
        $updateVals[] = "{$fields[$i]} = '{$values[$i]}'";
    }
}

$updateNames = '';
if(count($updateVals))
{
$updateNames =  ", " . implode(', ', $updateVals);
}

$update = "INSERT INTO image
               (mid, cid, item, price, about, name1, name2, name3, name4)
           VALUES
               ('$mid', '$cat', '$item', '$price', '$about', '$values[1]', '$values[2]', '$values[3]', '$values[4]')
           ON DUPLICATE KEY UPDATE
                cid = '$cat', item = '$item', price = '$price', about = '$about' $updateNames";
$result = mysql_query($update) or die (mysql_error());

$id = mysql_insert_id();

?>

Your Item Has Been Uploaded!
 
See less See more
Status
Not open for further replies.
You have insufficient privileges to reply here.
Top