1
0
Fork 0

Current timestamp set as default for mysql so no need to insert with NOW().

This commit is contained in:
Andrew Tomaka 2011-11-04 11:30:56 -04:00
parent 46daba6d60
commit e9ec301ec7
1 changed files with 11 additions and 3 deletions

View File

@ -9,6 +9,14 @@
* @version 1
**/
//for testing
$conf = (object)array(
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'screens',
);
define('UPLOADS','uploads/');
$extensions = array('jpg','jpeg','png','gif','bmp');
@ -31,12 +39,12 @@ if(array_key_exists('image', $_FILES)) {
$db = mysqli_init();
$db->real_connect($conf->hostname, $conf->username, $conf->password, $conf->database);
$query = "INSERT INTO screens (extension, original, created) VALUES('$extension','$original',NOW())";
$query = "INSERT INTO screens (extension, original) VALUES('$extension','$original')";
$db->query($query);
$newId = $db->insert_id;
if(move_uploaded_file($file['tmp_name'], UPLOADS . $file['name'])) {
echo json_encode(array('type'=>'success','status'=>'Uploaded successfully','file'=>'http://screens.p5dev.com/' . UPLOADS . $newId . $extension));
if(move_uploaded_file($file['tmp_name'], UPLOADS . $newId . '.' . $extension)) {
echo json_encode(array('type'=>'success','status'=>'Uploaded successfully','file'=>'http://screens.p5dev.com/' . UPLOADS . $newId . '.' . $extension));
exit;
}
}