473,322 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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.jpeg';
//$filename = 'Kids2.jpeg';
$percent = 0.5;

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

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

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

echo "step";

// Load
//$thumb = imagecreatetruecolor($newwidth, $newheight);
//echo "1 step";
$source= @imagecreatefromjpeg($filename);
$textcolor = imagecolorallocate($source, 0, 0, 255);
imagestring($source, 1, 5, 5, "Error loading $imgname",$textcolor);
//$source = imagecreatefromjpeg($filename);
echo "2 step";

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

// Output
imagejpeg($thumb);
echo "successfully completed";
?>

it returns the following error

getimagesize(\bala\testPHP\Lavanya\Kids2.jpeg): failed to open stream: No such file or directory in /home/bcns/public_html/bala/testPHP/Lavanya/imageprocess.php on line 13
step
Feb 1 '07 #1
1 2985
Motoma
3,237 Expert 2GB
My php program to resize an jpeg image is as follows,

?php
// File and new size

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

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

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

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

echo "step";

// Load
//$thumb = imagecreatetruecolor($newwidth, $newheight);
//echo "1 step";
$source= @imagecreatefromjpeg($filename);
$textcolor = imagecolorallocate($source, 0, 0, 255);
imagestring($source, 1, 5, 5, "Error loading $imgname",$textcolor);
//$source = imagecreatefromjpeg($filename);
echo "2 step";

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

// Output
imagejpeg($thumb);
echo "successfully completed";
?>

it returns the following error

getimagesize(\bala\testPHP\Lavanya\Kids2.jpeg): failed to open stream: No such file or directory in /home/bcns/public_html/bala/testPHP/Lavanya/imageprocess.php 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]
Feb 1 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: One | last post by:
I have a main.php file that calls a php navigation menu. I want to pass the menu file a parameter to tell it which menu to display. Inside the main.php I have : include...
1
by: kencana | last post by:
Hi all, I was wondering why I always get "failed to open stream: HTTP request failed!" error in either loading a normal or xml file. i don't understand why i can't get the whole result. the result...
16
by: Gary Wessle | last post by:
Hi please help with this. std::fstream iofs( f.c_str(), std::ios::in|std::ios::out ); std::cout << f << '\n' << iofs.is_open() << std::endl; puts out...
2
by: simbarashe | last post by:
Hie I'm trying to pass variables between pages using URLs however I am encountering the following error when I do so: Warning: main(jobSheetDisplay.php?id=20071403PB136CoA) : failed to open...
0
by: prasenjit2007 | last post by:
I have a main form for inputing the (to/from/mesg/file) with the following code:- <html> <body> <table> <tr> <td>To:</td> <td><input type="text" name="to" size="50" ...
5
by: xieliwei | last post by:
I have a freshly installed openSuSe 10.2 with PHP4 from http://download.opensuse.org/repositories/home:/michal-m:/php4/openSUSE_10.2/ (openSuSe abandoned PHP4 since version 10, but I have customers...
6
by: Andy2500 | last post by:
Hi, I'd like to upload an image to a folder, then I have 3 diffrents examples but all of them give an error "failed to open stream: Permission denied", althrough the C:\Inetpub\wwwroot is not...
2
by: swethak | last post by:
Hi, when i run my code it gives error as fopen(lib/providers//provider.RVLogic.php): failed to open stream: Permission denied in F:\Facebook\furniture11\Data...
5
by: tyakimov | last post by:
Hi guys I got a problem On my IIS server I changed the password for the Internet Guest Account 'IUSR_Machine' and suddenly the PHP part of the intranet stopped working. - '... failed to open...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.