コード例 #1
0
ファイル: upload.php プロジェクト: matthisamoto/Graphfan
} else {
    $replacing = false;
}
$folder = isset($_POST["folder"]) ? sqlescape($_POST["folder"]) : false;
$f = $_FILES["file"];
$file_name = $replacing ? $replacing : $f["name"];
// If the user doesn't have permission to upload to this folder, throw an error.
$perm = $admin->getResourceFolderPermission($folder);
if ($perm != "p") {
    $f["error"] = 9;
}
$error = false;
// Check for file upload errors (or the permission error we faked above)
if ($f["error"]) {
    if ($f["error"] == 2 || $f["error"] == 1) {
        $error = "The uploaded file was too large. (" . BigTree::formatBytes(BigTree::uploadMaxFileSize()) . " max)";
    } elseif ($f["error"] == 9) {
        $error = "You do not have permission to upload to this folder.";
    } else {
        $error = "The upload failed (unknown error).";
    }
    // File successfully uploaded
} elseif ($f["tmp_name"]) {
    $storage = new BigTreeStorage();
    $temp_name = $f["tmp_name"];
    // See if this file already exists
    if ($replacing || !$admin->matchResourceMD5($temp_name, $_POST["folder"])) {
        $md5 = md5_file($temp_name);
        // Get the name and file extension
        $n = strrev($file_name);
        $extension = strtolower(strrev(substr($n, 0, strpos($n, "."))));
コード例 #2
0
ファイル: upload.php プロジェクト: kurt-planet/BigTree-CMS
$successes = 0;
// This is an iFrame, so we're going to call the parent from it.
echo '<html><body><script>';
// If the user doesn't have permission to upload to this folder, throw an error.
$perm = $admin->getResourceFolderPermission($folder);
if ($perm != "p") {
    echo 'parent.BigTreeFileManager.uploadError("You do not have permission to upload to this folder.");';
} else {
    foreach ($_FILES["files"]["tmp_name"] as $number => $temp_name) {
        $error = $_FILES["files"]["error"][$number];
        $file_name = $replacing ? $replacing : $_FILES["files"]["name"][$number];
        // Throw a growl error
        if ($error) {
            $file_name = htmlspecialchars($file_name);
            if ($error == 2 || $error == 1) {
                $errors[] = $file_name . " was too large " . BigTree::formatBytes(BigTree::uploadMaxFileSize()) . " max)";
            } else {
                $errors[] = "Uploading {$file_name} failed (unknown error)";
            }
            // File successfully uploaded
        } elseif ($temp_name) {
            // See if this file already exists
            if ($replacing || !$admin->matchResourceMD5($temp_name, $_POST["folder"])) {
                $md5 = md5_file($temp_name);
                // Get the name and file extension
                $n = strrev($file_name);
                $extension = strtolower(strrev(substr($n, 0, strpos($n, "."))));
                // See if it's an image
                list($iwidth, $iheight, $itype, $iattr) = getimagesize($temp_name);
                // It's a regular file
                if ($itype != IMAGETYPE_GIF && $itype != IMAGETYPE_JPEG && $itype != IMAGETYPE_PNG) {