469,328 Members | 1,316 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,328 developers. It's quick & easy.

imagecreatefromgif not working

Hi, I've tried to upload a picture using the function
imagecreatefromgif, with a script as simple as possible to avoid miss
spellings and stuff like that. I've ran the following line of code to
see if my host had the right gd lib, and it was positive:

<?PHP print_r(gd_info()); ?>

so if it's not the server, what am i missing?
Here is my tiny script as it looks now:

<?php
function billede()
{
$bill = imageCreateFromGIF ("hindenburg.gif");
return $bill;
}
billede();
?>

Thanks for your help :)

Aug 10 '06 #1
16 6101
What's the error message ?
"moxmormor" <mo*******@gmail.coma écrit dans le message de news:
11**********************@i3g2000cwc.googlegroups.c om...
Hi, I've tried to upload a picture using the function
imagecreatefromgif, with a script as simple as possible to avoid miss
spellings and stuff like that. I've ran the following line of code to
see if my host had the right gd lib, and it was positive:

<?PHP print_r(gd_info()); ?>

so if it's not the server, what am i missing?
Here is my tiny script as it looks now:

<?php
function billede()
{
$bill = imageCreateFromGIF ("hindenburg.gif");
return $bill;
}
billede();
?>

Thanks for your help :)



Aug 10 '06 #2

Bob Bedford wrote:
What's the error message ?
"moxmormor" <mo*******@gmail.coma écrit dans le message de news:
11**********************@i3g2000cwc.googlegroups.c om...

There was no error message. The screen was just blank.

http://www.moxmormor.org/node.php

Aug 10 '06 #3
"moxmormor" <mo*******@gmail.coma écrit dans le message de news:
11**********************@m73g2000cwd.googlegroups. com...

Bob Bedford wrote:
What's the error message ?
"moxmormor" <mo*******@gmail.coma écrit dans le message de news:
11**********************@i3g2000cwc.googlegroups.c om...

There was no error message. The screen was just blank.

http://www.moxmormor.org/node.php

Are you sure about the file path ? try to add the complete path of the file,
maybe with a if file_exists() to be sure...and print an error message if it
doesn't exists.

Aug 10 '06 #4
Are you sure about the file path ? try to add the complete path of the file,
maybe with a if file_exists() to be sure...and print an error message if it
doesn't exists.

Now I'm confused. When it executed the following script, the output was
'nonexistant'.

<?php
function billede()
{
if (!file_exists('hindenburg.gif'))
{
$bill = imageCreateFromGIF ('hindenburg.gif');
return $bill;
}
else
echo "nonexistant";
}
billede();
?>

However, when I changed 'hindenburg.gif' to
'moxmormor_org/htdocs/hindenburg.gif' it went blank again.

Aug 10 '06 #5
Are you sure about the file path ? try to add the complete path of the file,
maybe with a if file_exists() to be sure...and print an error message if it
doesn't exists.

Now I'm confused. When it executed the following script, the output was
'nonexistant'.

<?php
function billede()
{
if (!file_exists('hindenburg.gif'))
{
$bill = imageCreateFromGIF ('hindenburg.gif');
return $bill;
}
else
echo "nonexistant";
}
billede();
?>

However, when I changed 'hindenburg.gif' to
'moxmormor_org/htdocs/hindenburg.gif' it went blank again.

Aug 10 '06 #6

"moxmormor" <mo*******@gmail.coma écrit dans le message de news:
11**********************@i42g2000cwa.googlegroups. com...
>Are you sure about the file path ? try to add the complete path of the
file,
maybe with a if file_exists() to be sure...and print an error message if
it
doesn't exists.


Now I'm confused. When it executed the following script, the output was
'nonexistant'.

<?php
function billede()
{
if (!file_exists('hindenburg.gif'))
{
$bill = imageCreateFromGIF ('hindenburg.gif');
return $bill;
}
else
echo "nonexistant";
}
billede();
?>

However, when I changed 'hindenburg.gif' to
'moxmormor_org/htdocs/hindenburg.gif' it went blank again.
You shouldn't user a path like this, instead use server variables in order
to be sure:
change moxmormor_org/htdocs/hindenburg.gif
to $_SERVER['DOCUMENT_ROOT'].'/hindenburg.gif';

also be very carefull, on Linux the filesystem is case sensitive, so
hindenburg.gif <hindenburg.GIF
Bob

Aug 10 '06 #7
You shouldn't user a path like this, instead use server variables in order
to be sure:
change moxmormor_org/htdocs/hindenburg.gif
to $_SERVER['DOCUMENT_ROOT'].'/hindenburg.gif';

also be very carefull, on Linux the filesystem is case sensitive, so
hindenburg.gif <hindenburg.GIF
Bob
Thank you, but it's still nonexistant. :(

Aug 10 '06 #8
"moxmormor" <mo*******@gmail.coma écrit dans le message de news:
11**********************@b28g2000cwb.googlegroups. com...
>You shouldn't user a path like this, instead use server variables in
order
to be sure:
change moxmormor_org/htdocs/hindenburg.gif
to $_SERVER['DOCUMENT_ROOT'].'/hindenburg.gif';

also be very carefull, on Linux the filesystem is case sensitive, so
hindenburg.gif <hindenburg.GIF
Bob

Thank you, but it's still nonexistant. :(
try a echo $_SERVER['DOCUMENT_ROOT'].'/hindenburg.gif' to be sure, maybe
your config root is wrong (pointing to the wrong file). Also to be sure, put
everything in a var:

$filename = $_SERVER['DOCUMENT_ROOT'].'/hindenburg.gif';
echo $filename;
if(file_exists($filename))
echo 'file exists';
else
echo 'file doesnt exist';

Bob

Are you on linux or XP ?

Aug 10 '06 #9
try a echo $_SERVER['DOCUMENT_ROOT'].'/hindenburg.gif' to be sure, maybe
your config root is wrong (pointing to the wrong file). Also to be sure, put
everything in a var:

$filename = $_SERVER['DOCUMENT_ROOT'].'/hindenburg.gif';
echo $filename;
if(file_exists($filename))
echo 'file exists';
else
echo 'file doesnt exist';

Bob
Pretty strange. Now the output is that the file is nonexistant, then
the full path, then that the file DOES exist.

>
Are you on linux or XP ?
I'm on a Linux server I'm pretty sure. Since they are operating with
php. My PC is XP.

Aug 10 '06 #10
"moxmormor" <mo*******@gmail.coma écrit dans le message de news:
11**********************@m79g2000cwm.googlegroups. com...
>try a echo $_SERVER['DOCUMENT_ROOT'].'/hindenburg.gif' to be sure, maybe
your config root is wrong (pointing to the wrong file). Also to be sure,
put
everything in a var:

$filename = $_SERVER['DOCUMENT_ROOT'].'/hindenburg.gif';
echo $filename;
if(file_exists($filename))
echo 'file exists';
else
echo 'file doesnt exist';

Bob

Pretty strange. Now the output is that the file is nonexistant, then
the full path, then that the file DOES exist.
Sorry I don't understand what you mean. What do you mean for output file ?
the full path is OK, are you sure on case (Linux is case sensitive,
remember), where the file DOES exists ?
>Are you on linux or XP ?

I'm on a Linux server I'm pretty sure. Since they are operating with
php. My PC is XP.
PHP can run on XP too, but if it's a professional web hosting, probably it's
on Linux.
On your page I've this result:
nonexistant/var/www/virtual/moxmormor.byethost11.com/moxmormor_org/htdocs/hindenburg.gifexistant
why there is a nonexistant and then an existant ? Your code is called twice
?
Could you send the entire code ? I'll check it for you.
I found the moxmormor.byethost11.com in your address quite strange altrough.
Bob

Aug 10 '06 #11

Bob Bedford wrote:
"moxmormor" <mo*******@gmail.coma écrit dans le message de news:
11**********************@m79g2000cwm.googlegroups. com...
try a echo $_SERVER['DOCUMENT_ROOT'].'/hindenburg.gif' to be sure, maybe
your config root is wrong (pointing to the wrong file). Also to be sure,
put
everything in a var:

$filename = $_SERVER['DOCUMENT_ROOT'].'/hindenburg.gif';
echo $filename;
if(file_exists($filename))
echo 'file exists';
else
echo 'file doesnt exist';

Bob
Pretty strange. Now the output is that the file is nonexistant, then
the full path, then that the file DOES exist.
Sorry I don't understand what you mean. What do you mean for output file ?
The output of my commands. The output, as you can see in the code,
tells me that the two paths are alike, but the one exists and the other
doesn't.
the full path is OK, are you sure on case (Linux is case sensitive,
remember), where the file DOES exists ?
yes, I've got everything in the same folder. And I have gained access
to textfiles in that folder before.
Are you on linux or XP ?
I'm on a Linux server I'm pretty sure. Since they are operating with
php. My PC is XP.
PHP can run on XP too, but if it's a professional web hosting, probably it's
on Linux.
On your page I've this result:
nonexistant/var/www/virtual/moxmormor.byethost11.com/moxmormor_org/htdocs/hindenburg.gifexistant
why there is a nonexistant and then an existant ? Your code is called twice
?
Could you send the entire code ? I'll check it for you.
Here it is:

<?php
function billede()
{
if
(!file_exists('/var/www/virtual/moxmormor.byethost11.com/moxmormor_org/htdocs/hindenburg.gif'))
{
$bill = imageCreateFromGIF
('/var/www/virtual/moxmormor.byethost11.com/moxmormor_org/htdocs/hindenburg..gif');
return $bill;
}
else
echo "nonexistant";
}
billede();
$filename = $_SERVER['DOCUMENT_ROOT'].'/hindenburg.gif';
echo $filename;
if(file_exists($filename))
echo 'existant';
else
echo 'nonexistant';
?>

Thank you for your effort :)
I found the moxmormor.byethost11.com in your address quite strange altrough.
I started with a free account at byethost to check it out. then I
changed to a paid solution, and got my public DNS changed or something.
There is a reasonable explanation, although I don't understand it ;)
Bob
Aug 10 '06 #12
moxmormor wrote:
Hi, I've tried to upload a picture using the function
imagecreatefromgif, with a script as simple as possible to avoid miss
spellings and stuff like that. I've ran the following line of code to
see if my host had the right gd lib, and it was positive:

<?PHP print_r(gd_info()); ?>

so if it's not the server, what am i missing?
Here is my tiny script as it looks now:

<?php
function billede()
{
$bill = imageCreateFromGIF ("hindenburg.gif");
return $bill;
}
billede();
?>
What are you expecting the script to do? It doesn't actually do
anything. It just open the gif file and doesn't produce any output.

Aug 10 '06 #13
What are you expecting the script to do? It doesn't actually do
anything. It just open the gif file and doesn't produce any output.
OK then that's why. I just expected the return statement did the job.
How should i then show the image once I've opened it?

Aug 10 '06 #14
Try this:

<?php
function billede($filename){
if(!file_exists($filename)){
$bill = imageCreateFromGIF($filename);
return $bill;
}else
echo "file already existent, cannot create new file<br>";
}
$filename = $_SERVER['DOCUMENT_ROOT'].'/hindenburg.gif'; //this avoid a lot
of problem. Typing manually the file will get you into trouble later...
echo $filename.'<br>';
$img = billede($filename);
/*if(file_exists($filename))
echo 'existant'; //should always be called has it would be created if it
wasn't existent before or already exists.
else
echo 'nonexistant';*/
?>
>Thank you for your effort :)
np.

try this code and let me know.

Bob

Aug 10 '06 #15

Bob Bedford wrote:
Try this:

<?php
function billede($filename){
if(!file_exists($filename)){
$bill = imageCreateFromGIF($filename);
return $bill;
}else
echo "file already existent, cannot create new file<br>";
}
$filename = $_SERVER['DOCUMENT_ROOT'].'/hindenburg.gif'; //this avoid a lot
of problem. Typing manually the file will get you into trouble later...
echo $filename.'<br>';
$img = billede($filename);
/*if(file_exists($filename))
echo 'existant'; //should always be called has it would be created if it
wasn't existent before or already exists.
else
echo 'nonexistant';*/
?>
Thank you for your effort :)

np.

try this code and let me know.

Bob

what i wanted to was to show the current gif image on my site, using
php. I think I might have misunderstood the consequences of the
imageCreateFromGIF function.
But thanks anyway:)

Aug 10 '06 #16
Rik
moxmormor wrote:
>What are you expecting the script to do? It doesn't actually do
anything. It just open the gif file and doesn't produce any output.

OK then that's why. I just expected the return statement did the job.
How should i then show the image once I've opened it?
imagegif(), imagejpeg(), imagepng() etc..

imagecreatfrom..() creates an image identifier, not an image.

But why create an image in memory, and then return the same image? Unless
you do something in between, a link to the file er even readfile() is more
efficiënt.

Grtz,
--
Rik Wasmus
Aug 10 '06 #17

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Gary | last post: by
6 posts views Thread by Mullin Yu | last post: by
5 posts views Thread by Martin Heuckeroth | last post: by
5 posts views Thread by tshad | last post: by
8 posts views Thread by jojobar | last post: by
2 posts views Thread by Don | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Purva khokhar | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.