Jump to content

Archived

This topic is now archived and is closed to further replies.

digitalgod

mkdir - Bad File Descriptor

Recommended Posts

hey guys,

I have this pic upload system that creates the folder if it doesn't exist and makes a thumbail of the pic. It worked perfectly a while ago but now from time to time it won't upload a file saying that it doesn't have Permission and if I try to delete other folders it gives me a Bad File Descriptor error...

is it because of my code or something??

here's an example
[code]
<?php
function createthumb($name, $filename, $new_w, $new_h)
{
    $system = explode('.', $name);
    if (preg_match('/jpg|jpeg/', $system[1])) {
        $src_img = imagecreatefromjpeg($name);
    }
    if (preg_match('/png/', $system[1])) {
        $src_img = imagecreatefrompng($name);
    }
    $old_x = imageSX($src_img);
    $old_y = imageSY($src_img);
    if ($old_x > $old_y) {
        $thumb_w = $new_w;
        $thumb_h = $old_y * ($new_h / $old_x);
    }
    if ($old_x < $old_y) {
        $thumb_w = $old_x * ($new_w / $old_y);
        $thumb_h = $new_h;
    }
    if ($old_x == $old_y) {
        $thumb_w = $new_w;
        $thumb_h = $new_h;
    }

    $dst_img = ImageCreateTrueColor($thumb_w, $thumb_h);
    imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y);

    if (preg_match("/png/", $system[1])) {
        imagepng($dst_img, $filename);
    } else {
        imagejpeg($dst_img, $filename);
    }
    imagedestroy($dst_img);
    imagedestroy($src_img);
}


$upload_par = "img/clubs";
$upload_dir = $upload_par . "/" . $name . "/";
$upload_tdir = $upload_dir . "thumbnails/";
$num_files = 1;

if (!is_dir("$upload_par")) {
    mkdir($upload_par);
}
if (!is_dir("$upload_dir")) {
    mkdir($upload_dir);
    mkdir($upload_tdir);
}

$new_file = $_FILES['file'];
$file_name = $new_file['name'];
$file_tmp = $new_file['tmp_name'];

if (move_uploaded_file($file_tmp, $upload_dir . $file_name)) {
    array_push($names, $file_name);
    createthumb($upload_dir . $file_name, $upload_tdir . $file_name, 125, 125);
} else {
    echo "File $i: Faild to upload.<br>";
}
?>
[/code]

anyone know why that happens to my folders/files?? It's really annoing

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.