Working with PHP. I want to display the images which are in xampp folder not in htdocs (which will be root of the website). How to go about it? I have tried <img src="../../image.jpg", and also tried with src=/image.jpg, not working. Given the total path as src="E:/xampp/image.jpg" still not working. What may be wrong. The file is .php
You can't access pictures (or files) outside of htdocs on a webpage.
There are probably ways to retrieve the image from a directory "lower" than htdocs with PHP (depending on your open_basedir-restrictions), store them somewhere else and let the img-tag display them or really mess with your server settings to allow access ... but why don't you just place the images somewhere in htdocs (or a subdirectory), where they belong?
You cant access images/css sheets etc outside htdocs folder
Make a folder for images in htdocs and use those
Related
How is it with the img/p folder in Prestashop 1.6.0.9? Is it possible fully to clean it? Cause this folder went to big now, and FTP is almost full now, i need space. For example when i renamed it on FTP, all images on the website worked, and prestashop created automaticaly one new img/p folder, and all seems that works right (also when the initial img/p was out after renaming). Thanks in advance.
when you delete the folder you may see the images working, its from smarty cache, once you clear the smarty cache, presta default (not found) image will be shown.
I have followed Drupal's tutorial on how to successfully run a Windows server using xampp. I think I've done everything right, but when I go to my website, it goes to mywebsite/xampp.
Does anyone know what I need to do to solve this?
Which folder did you put your website files? What address did you type in the address bar? If using localhost or any other domain which redirects there, be sure you rename any index.php or index.html in the server root folder (htdocs). This is because most servers look for any file named this way when visiting any server folder and will automatically display that page when it finds it.
In this case since you freshly installed xampp, their homepage is probably set to show by default
For example look at the picture. This is the index.php file in the htdocs folder. At the top you can see I've added a header to redirect to somewhere else. Below I commented out the code that was defaulted by the xampp installation, which pretty much said to relocate to the xampp/ directory (which then loads the index file there). If it failed to go there, you should see the message at the bottom
Something is wrong with your xampp installation :-(
If you're being redirected to the xampp/ directory you simply need to rename or edit the index.php file in the htdocs folder.
Ideally you should make a separate folder for your website in the htdocs folder, something like htdocs/myWebsite.
You can name your homepage either index.html or index.php (depending on which language you use) and then go to localhost/myWebsite and it will automatically load your homepage.
I am hosting a website on the localhost of a VPS using XAMPP.
When I go to the website be it on the VPS directly through localhost or remotely from my own computer - images are not loading and appearing as broken and when I try to view the image directly I am given an error 404 and object not found.
The image paths are completely correct in corresponding to htdocs.
For example,
http://mysite.com/icons/pixels.gif
I copied that link, checked htdocs and that is exactly where the image should be yet I am given an error 404 and object not found.
HOWEVER.
Out of chance I changed the \icons\ from an 'i' to a capital and the image loaded normally. The icons folder in htdocs does not have a capital letter.
The problem may be my .htaccess file though, here is a link to it: http://pastebin.com/vUnhjb2A
I'm using windows 7 (64 bit).
If I place a site (index.php, other docs and other sub folders [css, js, imgs etc]
directly inside the htdocs folder (amongst the XAMPP folders)
and view the site through localhost there is no problem.
If instead the site is placed in a subfolder of htdocs, C:xampp/htdocs/mysite,
and I try to view index.php all links (relative) to subfolders (eg images, css and js etc) stop working.
I obviously would prefer to use xampp for more than one site, so i want to have a sub folder in htdocs for each site.
Believe me I've been googling and I've looked at some 'solutions' (for example changing the httpd.conf for example, would mean changing it each time i want to view a different site....) but nothing has helped. What things should I be checking out?
Edits
LINKS FORMATTING
href="/css/homeAreaStyle111.css"
data="/svg/linkedbutton.svg"
Are you preceeding your links with a slash? Ie
<a href=/page.htm>
If so those links will be pointing to the site root. Try replacing with ex
<a href=page.htm>
or
<a href=./page.htm>
In case you have your website at C:xampp/htdocs/mysite then your links will look like:
href="/mysite/css/homeAreaStyle111.css"
data="/mysite/svg/linkedbutton.svg"
I am creating a project wherein the user can upload his photo. This photo is stored in the folder "images/uploads/filename". When his profile is created and the photo is to be shown, I use the <img> tag with src as "images/uploads/filename", but the photo does not show up.
If I manually copy the photo to an adjacent folder "images/abc/filename" and then use it as the source then it works.
How is this caused and how can I solve it? I need to use the same folder to upload and download photos.
That can happen if you're running the webapp as an IDE project and are storing the uploaded images in the IDE's project space. Changes in the IDE's project folder which are performed externally (as by your servlet code) does not immediately get reflected in the deployed server's work folder. Only when you touch it (by refreshing the project) or by copying it (as you happen to have found out), then it will get reflected.
After all, storing uploaded files in the webapp's deploy folder is a bad idea. Those files will get all lost whenever you redeploy the webapp, simply because those files are not contained in the original WAR file.
You need to store them somewhere outside the webapp's deploy folder on a different fixed path like /var/webapp/uploads. You should not use relative paths or getRealPath() to create the File object around it. Just use a fixed path. You can always make the fixed path configureable as a context param setting, a VM argument, a properties file setting or even a JNDI entry.
Then, to serve it to the world wide web, just add exactly that path as another docroot to the server config. It's unclear what server you're using, but in Tomcat it's a matter of adding another <Context> to the server.xml.
See also:
Uploaded image only available after refreshing the page
How I save and retrieve an image on my server in a java webapp
Make sure your have the correct path and include the image extension
just for testing, put your img tag inside the index.php
<img src="images/abc/filename.jpg">
/root/index.php
now put you image in to the your abc/ folder
/root/images/abc/filename.jpg
This should display the image.
if you have your img tag inside another folder in the root like below
/root/user/index.php
now when you use you img tag use this path (relative link):
<img src="../images/abc/filename.jpg">
note the beginning of the image path "../" this is used to go back to the root.
if the php or html file that is holding the img tag is even deeper, just remember to add ../ for every level, 2 folders deep whould be:
<img src="../../images/abc/filename.jpg">
Question was quite vague so hope this is what you are looking for.
let me know and if this is wrong, explain a little more and i will try to help :)