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" />
Related
I am trying to display an image that I manually uploaded using the cPanel File Manager (or Eclipse Import), using the following in a View:
<img src="/app/public/images/logos/DoesNotShow.jpg">
and it does NOT show up. When I take another jpg that already existed:
<img src="/app/public/images/logos/DoesShow.jpg">
it displays perfectly. If I download DoesShow.jpg from the cPanel File Manager, rename it WillThisShow.jpg, and then upload (using cPanel File Manger) WillThisShow.jpg to the same folder, and put the following in the view:
<img src="/app/public/images/logos/WillThisShow.jpg">
it also does NOT display.
I inspected the non-uploaded and the uploaded, and the full correct path was shown for both.
Any ideas?
Make sure you have sent your base url $config['base_url'] = 'http://example.com/' end it with / so you dont have to use it on view. Also make sure you images are outside of the application
application
app
app > public
system
index.php
config/autoload the url helper.
Then on the image
<img src="<?php echo base_url('app/public/images/logos/WillThisShow.jpg');?>"
Use this If your baseUrl not ending with / eg: http://demo.com then
<img src="<?php echo base_url();?>/app/public/images/logos/DoesNotShow.jpg">
OR
Change the permission to 0644
I've been looking for a way to make a custom direct access images on wp-content uploads folder since a year ago, but I still didn't found how to serve / display image in wp-content/uploads folder using custom script (maybe php)
Please take a look at my screensshot here : http://prntscr.com/30sdb8
you can see this wp-content/uploads are still have some additional code, and even this page source are hidden with an image (the same image)
is there anyone know how to do that on a worpdress website?
Thanks for answering my question
Updated
because of some unclearly information in my previous question here I try to explain as clear as I can.
In a default wordpress website if a user direct access an image from wp-content/uploads/ directory (for an example : www.domain.tld/wp-content/uploads/2014/04/image-name.jpg )
there will be only an image and a blank background, but in my screenshot example you can see that there are some additional code in header and footer.
my question is how to make modification like that in wordpress? so I can display a header and of footer on my wp-content/uploads/ Url pages
ps : the website I mean is lincah.com , you can go to google image, site:lincah.com then click on 1 image on the search result you'll be brought to the page I mean.
I hope thats clearly enough.
Thank you
What I could make out is you need a PHP script that could fetch all the images from uploads folder and display on the page.
<?php
$images_list = glob("wp-content/uploads/" . "*");
foreach($images_list as $image) {
echo '<img src="' . $image . '" /> <br />';
}
?>
Just a quick questions guys. I'm using a 'browse' upload function within a form to select and upload a picture to my database. At the moment my images are in a 'Image' folder and to get them to show I need the following within my Image column:
Images\picname1.jpg
When I use the browse upload function, I get the following:
E:\xampp\htdocs\IDB\images\picname1.jpg
which is the displayed on the database as:
picname1.jpg
And of course as the 'Image' folder directory isn't included, the image will not display.
This is my form:
<font face="Arial"><b>Enter Image(Optional):</b></font><input type="file" name="imaAdd" accept="image/gif">
Could anyone tell me how I can include the 'Image directory!? I'm sure its an obvious fix I'm missing!
Any help would be great!
Edit:
Hers my Image echo guys.
echo"<img src='".$row->Image."'>";
One option would be to concatenate the string 'images/' with the image filename upon insertion into your database.
A better option would probably be to qualify the filename with the images path when you go to display the image. If you can show us the code you use to display the images, it should be an easy fix.
The PHP code for this latter option could look like:
echo '<img src="images\' . $imagename . '" />';
I'm slightly confused by what you are asking, correct me if im wrong but this is what you have:
An upload system that uploads pictures to your image directory and adds imageName.jpg to your database. And you want to prefix 'images\' to each of the image names added to your database?
If thats the case, in your php script that the form triggers you should be able to set the image name as added to the db as 'image\.$imagename' assuming $imagename as the name of the image.
And if that does not work why not prefix it while accessing the img? print '<img src=image\"'.$imagename.'" />
Hope that helps.
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']}\" />"