| Server IP : 74.208.250.37 / Your IP : 216.73.216.114 Web Server : Apache/2.4.58 (Ubuntu) System : Linux ubuntu 6.8.0-124-generic #124-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 13:00:45 UTC 2026 x86_64 User : miferval ( 1000) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/aprendizajeodisea/app/uploads/ |
Upload File : |
<?php
/*
* TEST
*/
// requires php5
if(!isset($db)){
require_once('../../system/ajax_bootstrap.php');
}
switch ($_GET['uploadcategory']) {
case 'article':
define('UPLOAD_DIR', 'images/'.date('Y').'/'.date('m').'/');
break;
case 'admins':
define('UPLOAD_DIR', 'admins/');
break;
case 'ads':
define('UPLOAD_DIR', 'ads'.date('Y').'/'.date('m').'/ads/');
break;
case 'video':
define('UPLOAD_DIR', 'video/'.date('Y').'/'.date('m').'/');
break;
default:
define('UPLOAD_DIR', 'images/'.date('Y').'/'.date('m').'/');
break;
}
//define('UPLOAD_DIR', 'images/'.date('Y').'/'.date('m').'/');
$img = $_POST['data'];
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace('data:image/jpeg;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$data = base64_decode($img);
//Create directory if do no exist
if (!is_dir(UPLOAD_DIR)) {
if (!mkdir(UPLOAD_DIR, 0777, true)) {
die('Failed to create folders...');
}
}
//Upload File
$filename = str_replace('app/uploads/'.UPLOAD_DIR, '', $_POST['name']);
$file = UPLOAD_DIR . $filename;
$success = file_put_contents($file, $data);
$success ? $status = 'success' : $status = 'fail';
//Send response
$response = array('status' => $status , "url" => $file , "filename" => $filename , "path" => "/app/uploads/".$file);
print json_encode($response);
//print_r($response);
//echo $response['url'];