Grow your CSS skills. Land your dream job.

Question about image admin panel

  • # June 28, 2008 at 3:26 am

    Hi,
    i followed a tutorial on how to create a image gallery with a admin panel, and when i tried to upload a image, it gave me this error:

    Warning: move_uploaded_file(C:/webroot/gallery/images/gallery/c1b55bfadb00c4304fb9f774eefafb93.png) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:xampplitehtdocsphpcmslibraryfunctions.php on line 21

    Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move ‘C:xampplitetmpphp22F.tmp’ to ‘C:/webroot/gallery/images/gallery/c1b55bfadb00c4304fb9f774eefafb93.png’ in C:xampplitehtdocsphpcmslibraryfunctions.php on line 21
    Error uploading file

    line 21 on functions.php is part of a function to upload the images:

    Code:
    function uploadImage($inputName, $uploadDir)
    {
    $image = $_FILES[$inputName];
    $imagePath = ”;
    $thumbnailPath = ”;

    if (trim($image['tmp_name']) != ”) {
    $ext = substr(strrchr($image['name'], “.”), 1);

    $imagePath = md5(rand() * time()) . “.$ext”;
    $result = move_uploaded_file($image['tmp_name'], $uploadDir . $imagePath);

    if ($result) {
    $thumbnailPath = md5(rand() * time()) . “.$ext”;
    $result = createThumbnail($uploadDir . $imagePath, $uploadDir . ‘thumbnail/’ . $thumbnailPath, THUMBNAIL_WIDTH);

    if (!$result) {
    unlink($uploadDir . $imagePath);
    $imagePath = $thumbnailPath = ”;
    } else {
    $thumbnailPath = $result;
    }
    } else {

    $imagePath = $thumbnailPath = ”;
    }

    }

    Can someone please explain what is going on?

    thanks,
    James

    box
    # June 28, 2008 at 8:17 am

    make sure that the upload directory /images/gallery/ is writable

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".