PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Depends on where the directory is located. Try using the full path to the directory, like /home/somebody/img.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
I changed $uploaddir to the following '../../img/' . Now readfile() spits out a ton of weird data, im assuming it has found the file (and it's not giving an error message anymore). Yet when i try to display the file with an img HTML tag, it still doesn't show the image. Is the IMG tag the correct way to display the image in this case?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
social_experiment wrote:I changed $uploaddir to the following '../../img/' . Now readfile() spits out a ton of weird data, im assuming it has found the file (and it's not giving an error message anymore). Yet when i try to display the file with an img HTML tag, it still doesn't show the image. Is the IMG tag the correct way to display the image in this case?
If the image is outside of the web root then the img tag will not display it because the image is not accessible. readfile() may work but you have to send the proper headers (content type, length, etc.).
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
AbraCadaver wrote:readfile() may work but you have to send the proper headers (content type, length, etc.).
It does indeed work, but it makes it difficult to include this image ,lets say use the image as a profile photo. The header('Content-Type: image/jpeg') seems to block any other text that you might want to display.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
You need to display the image in a PHP file and then have this file as the src of an img tag. Here is something similar just with an image from a database: viewtopic.php?f=1&t=110171&p=582727#p582727
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.