real_connect($conf->hostname, $conf->username, $conf->password, $conf->database); $query = "INSERT INTO screens (extension, original) VALUES('$extension','$original')"; $db->query($query); $newId = $db->insert_id; if(move_uploaded_file($file['tmp_name'], UPLOADS . $newId . '.' . $extension)) { echo json_encode(array('type'=>'success','status'=>'Uploaded successfully','file'=>'http://screens.p5dev.com/' . $newId)); exit; } } error('unknown error'); function error($message) { echo json_encode(array('type'=>'error','status'=>$message)); exit; } ?>