Hacked By AnonymousFox

Current Path : /home/missmand/public_html/learning/maia/
Upload File :
Current File : /home/missmand/public_html/learning/maia/upload.php

<?php
header('Content-type: application/json');

// Create function to set http response code.
if (!function_exists('http_response_code'))
{
    function http_response_code($newcode = NULL)
    {
        static $code = 200;
        if($newcode !== NULL)
        {
            header('X-PHP-Response-Code: '.$newcode, true, $newcode);
            if(!headers_sent())
                $code = $newcode;
        }       
        return $code;
    }
}

if(!isset($_FILES["sound"])) {
    http_response_code(404);
    die();
}

$error = NULL;
$target_dir = "../file/audio/";
$target_filename = time() . '-' . basename($_FILES["sound"]["name"]);
$target_file = __DIR__ . '/' . $target_dir . $target_filename;

$soundFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));

// Check if file already exists
if (file_exists($target_file)) {
    $error = "Sorry, file already exists.";
}

// Check file size 50MB
if ($_FILES["sound"]["size"] > 50000000) {
    $error = "file is too large";
}

// Allow certain file formats
if($soundFileType != "mp3") {
    $error = "File format not supported";
}

// Check if $uploadOk is set to 0 by an error
if ($error != NULL) {
    http_response_code(500);
    echo json_encode(array("error"=>$error));
// if everything is ok, try to upload file
} else {

    if (move_uploaded_file($_FILES["sound"]["tmp_name"], $target_file)) {
        http_response_code(200);
        echo json_encode(array("error"=>$error, "file"=> $target_filename));
    } else {
        http_response_code(500);
        echo json_encode(array("error"=>'Error while uploading the file'));
    }
}
?>

Hacked By AnonymousFox1.0, Coded By AnonymousFox