this is my first time asking a question about this but unlike my other problems i have been unable to find the specific answer i am seeking. i am very new to php but it's working well on a current project.
i have this line of code which works perfectly in context of my page when the image file name is set to a specific name.
<?php echo $_SESSION['userName'];?>
<?php echo "<img src='videos/jpgs/'userName'.jpg' width='83'
height='20'/>"; ?>!
what i would like to do is open an image which uses the user name as the image filename. The images are in the folder in the path. The users are set internally and their user names are predetermined.
thanks in advance.
Use:
<?php echo "<img src='videos/jpgs/".$_SESSION['userName'].".jpg' width='83' height='20'/>"; ?>
<img src='videos/jpgs/<?php echo $_SESSION['userName']; ?>.jpg'/>
You could try this one too
Related
I need to insert php code within a text. It is an image but uses an absolute path through php. I would like to execute but the image is not displayed within the text.
<img class="image-left" src="<?php $_SERVER['DOCUMENT_ROOT']?>/abuelo/abuelo.png"/>Since the founding of Grandpa in 2003 we have offered a different type of shopping. We have always had service...
I always use in my projects Because I find very useful, if you change the place .php file or meta in a folder always find the images.
I would be very utilizad it can also be included in the database, in case I need to show information with your image added elsewhere on the page regardless of where the file is hosted.
Is there any way to insert the image in the database and make it work?
All you need is an echo
<img class="image-left" src="<?php echo $_SERVER['DOCUMENT_ROOT']; ?>/abuelo/abuelo.png"/>Since the founding of Grandpa in 2003 we have offered a different type of shopping. We have always had service...
Edited:
The problem is, you are referencing your image as,
C:/wamp/www/
which will never work. You should be referencing it as localhost. Like this:
<img src="<?php echo "http://" . $_SERVER['SERVER_NAME']; ?>/abuelo/abuelo.png" />
I have this problem, i have this script in php that creates a image on the fly, the problem is that the outputted image on the browser is allright, but i need to change it's name.
Ex: Index.php
<?php $url = "http://www.somesite.com/cls/image_scrc?_aaa=qJ7VgSxWBLG3FfNQVB%2BKI58kfHQulPHZLuLYaZAG6Tk%3D&_ab=3ctGTf547wdsAGjY%2F5FASE%2BpBnbQEAcrhbJzCHQ7mGs%3D&_acb=89e62acf3b4d254abf0c3ab30d6ebb33" ?>
<img src="<?php echo $url ?>" />
The image_scrc.php is the file that creates the image, and as you can see i have several data that is passed by the get method.
In the image_scrc.php i have tryed
header('Content-type: image/jpg');
header('Content-Disposition:inline; filename="'.$random_name_jpeg.'"');
but the html link is is always appearing like this
http://www.somesite.com/cls/image_scrc?_aaa=qJ7VgSxWBLG3FfNQVB%2BKI58kfHQulPHZLuLYaZAG6Tk%3D&_ab=3ctGTf547wdsAGjY%2F5FASE%2BpBnbQEAcrhbJzCHQ7mGs%3D&_acb=89e62acf3b4d254abf0c3ab30d6ebb33
if i select the image on browser and then select copy image link it copies just like this also.
however, when I save the image it assumes the random_name.jpg, but only on save!
i've tried everything, even htaccess rules but nothing seems to work !!
it's this possible to acomplish? transform this
http://www.somesite.com/cls/image_scrc?_aaa=qJ7VgSxWBLG3FfNQVB%2BKI58kfHQulPHZLuLYaZAG6Tk%3D&_ab=3ctGTf547wdsAGjY%2F5FASE%2BpBnbQEAcrhbJzCHQ7mGs%3D&_acb=89e62acf3b4d254abf0c3ab30d6ebb33
to this
http://www.somesite.com/cls/random_name.jpg
i cant have the image on the server side! and must be displayed on the fly
Thanks in advance.
The file is created when the user registers successfully , each user folder thats created is only read/writable by daemon not by admin or anyone else,
the main users folder is created by me and has all permissions set that needs be and it doesnt even feature the name daemon
The problem I have is that, when I upload an image, it uploads to the directory of that user(the right directory of the users name) and I see it there but the problem is when I want to echo the image onto the page it does not work.
I use the moveupload() function and it moves but it is not able to show the image on the page, all other information is shown on the users page like name ect , but just not the image .What can I do?
This is the code snippet to create the file when user registers . I'm using a mac
if(!file_exists("user/$u")) {
mkdir("user/$u",0755);
}
Are you using proper HTML syntax for echo-ing your image? You can't simply do an echo $imagePath; in PHP, you must user proper HTML syntax for the output.
echo "<img src='".$imagePath."' />";
Edit:
If you're using HTML mixed with php, the HTML output would be as follows:
HTML
<img src="<?php echo $log_userpath . "/" . $main_userimage;?>" width="220px" height="300px" />
I have created a form which takes in images into a folder. I have only one image per folder and I want to display the image from the specified folder.
Say I've uploaded one picture to folder name uploads. Now I want to retrieve that image from the folder and display it.
How do I do that?
When a file is uploaded with your form, it becomes a file on your server, immediately. The web server puts it in a temporary directory and PHP tells you where it was put through the $_FILES array. You can immediately access this file, you can move it somewhere within your website's documents, and you can immediately print out an <img> tag pointing to where the file was put.
Stop writing "an img tag won't work" as that is exactly how you display the image.
Read the PHP manual page "Handling file uploads":
http://php.net/manual/en/features.file-upload.php
The PHP manual should always be the first place you go when you're trying to do something you haven't done before.
<img src="/path/to/the/upload/folder/<?php echo $filename; ?>"/>
or:
echo '<img src="/path/to/the/upload/folder/'.$filename.'"/>";
First you should have the image and path (or user) names in PHP variables. Then use an IMG tag to display them like :
<img src="some_path/uploads/<?php echo $username . '/' . $imagename; ?>">
you can't do it without knowing the name of the image file.
<?php
header('Content-Type:image/jpeg');
readfile('path_to_your/image.jpg');
I've saved a user's respective picture in a folder named 'profileportraits'. So when a user uploads their picture, it is saved into that folder. Furthermore, I also save the 'portrait path', i.e. the location/name of the photo onto a MySQL database for user data. My question is: I am able to echo the Portrait Path, where the user's portrait is stored onto the page. But how will I display the actual photo onto the page? I.e. how can I turn the file path into the actual picture? Will I have to match the path that I retrieved from MySQL to the directory? or something else? Below is a bit of code.
{
echo $row['PortraitPath'];
}
With the code above, I am able to echo the actual path, which is: profileportraits/DSC00310.JPG. I simply want to turn this path of the picture, into the actual picture. Thank you.
<img src="<?php echo $row['PortraitPath']; ?>" />
or
<?php
echo "<img src=\"{$row['PortraitPath']}\" />";
?>
Why not use the path as the source of an image tag:
echo "<img src=\"{$row['PortraitPath']}\" />"