failed to open stream error in php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • krishna5
    New Member
    • Feb 2007
    • 4

    failed to open stream error in php

    My php program to resize an jpeg image is as follows,

    ?php
    // File and new size

    $filename = '\bala\testPHP\ Lavanya\Kids2.j peg';
    //$filename = 'Kids2.jpeg';
    $percent = 0.5;

    // Content type
    //header('Content-type: image/jpeg');

    // Get new sizes
    list($width, $height) = @getimagesize($ filename);
    echo getimagesize($f ilename);

    $newwidth = $width * $percent;
    $newheight = $height * $percent;

    echo "step";

    // Load
    //$thumb = imagecreatetrue color($newwidth , $newheight);
    //echo "1 step";
    $source= @imagecreatefro mjpeg($filename );
    $textcolor = imagecoloralloc ate($source, 0, 0, 255);
    imagestring($so urce, 1, 5, 5, "Error loading $imgname",$text color);
    //$source = imagecreatefrom jpeg($filename) ;
    echo "2 step";

    // Resize
    imagecopyresize d($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

    // Output
    imagejpeg($thum b);
    echo "successful ly completed";
    ?>

    it returns the following error

    getimagesize(\b ala\testPHP\Lav anya\Kids2.jpeg ): failed to open stream: No such file or directory in /home/bcns/public_html/bala/testPHP/Lavanya/imageprocess.ph p on line 13
    step
  • Motoma
    Recognized Expert Specialist
    • Jan 2007
    • 3236

    #2
    Originally posted by krishna5
    My php program to resize an jpeg image is as follows,

    ?php
    // File and new size

    $filename = '\bala\testPHP\ Lavanya\Kids2.j peg';
    //$filename = 'Kids2.jpeg';
    $percent = 0.5;

    // Content type
    //header('Content-type: image/jpeg');

    // Get new sizes
    list($width, $height) = @getimagesize($ filename);
    echo getimagesize($f ilename);

    $newwidth = $width * $percent;
    $newheight = $height * $percent;

    echo "step";

    // Load
    //$thumb = imagecreatetrue color($newwidth , $newheight);
    //echo "1 step";
    $source= @imagecreatefro mjpeg($filename );
    $textcolor = imagecoloralloc ate($source, 0, 0, 255);
    imagestring($so urce, 1, 5, 5, "Error loading $imgname",$text color);
    //$source = imagecreatefrom jpeg($filename) ;
    echo "2 step";

    // Resize
    imagecopyresize d($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

    // Output
    imagejpeg($thum b);
    echo "successful ly completed";
    ?>

    it returns the following error

    getimagesize(\b ala\testPHP\Lav anya\Kids2.jpeg ): failed to open stream: No such file or directory in /home/bcns/public_html/bala/testPHP/Lavanya/imageprocess.ph p on line 13
    step

    The slashes '\' are in the wrong direction for your filename. They should be '/'.
    [PHP]
    $filename = '/bala/testPHP/Lavanya/Kids2.jpeg';
    [/PHP]

    Comment

    Working...