real_connect($conf->hostname, $conf->username, $conf->password, $conf->database); $query = "INSERT INTO screens (extension, original, created) VALUES('$extension','$original',NOW())"; $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)); exit; } } error('unknown error'); function error($message) { echo json_encode(array('type'=>'error','status'=>$message)); exit; } ?>