Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

PHP Beginner - Broken links to images

New Here ,
Aug 15, 2009 Aug 15, 2009

Hi:

I'm setting up my first PHP development environment for an existing web site.  I created a new site, set up the php environment and then downloaded all of the files from the web hosting company.  There are two folders on the web server (cgi-bin and htdocs).  The site on my local computer is located in c:/xampp/htdocs/scarabMotorsports.  When I downloaded the two folders from the web server the folders were copied to the scarabMotorsports directory so now I have a htdocs folder and cgi-bin folder in the scarabMotorsports directory.  When I try to view the php pages in design mode in dreamweaver all of the links to the images are broken.  I believe I need to change the way my environment is set up but I'm not sure what to do.  I was wondering if I should remove all of the files from the htdocs folder and place them directly in the scarabMotorsports directory?  Would this correct the broken links?  This is the current directory structure on my pc (c:/xampp/htdocs/scarabMotorsports/htdocs/...this is where all of the php files, images, etc... are located).  Should I change the directory structure to c:/xampp/htdocs/scarabMotorsports/...place the php files, images, etc...directly in the scarabMotorsports directory?  Any suggestions would be appreciated!

TOPICS
Server side applications
936
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Aug 15, 2009 Aug 15, 2009

View the site locally, look at the source, and see where the images should be located. Place the images in the appropriate directory. Can't say where the images should be placed because it's unknown where they should be, only you know where they should be because you can see intended directory in source.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 15, 2009 Aug 15, 2009

The images on the hosting company's web server are located in the htdocs/img folder.  The images in the local view on my pc are located at c;/xampp/htdocs/scarabMotorsports/htdocs/img.  If I change the path of the images to c:/xampp/htdocs/scarabMotorsports/img in each php file and then upload the php files to the hosting company's web server, won't that cause the links to become broken on the hosting company's web server?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Aug 15, 2009 Aug 15, 2009

set img path relative to site root to access image both locally and on server.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 16, 2009 Aug 16, 2009
LATEST

www.DwFAQ.info wrote:

set img path relative to site root to access image both locally and on server.

That won't work, because xampp/htdocs will be regarded as the site root.

When developing locally in a subfolder of htdocs, you should always set the site definition to use links relative to the document.

Use the following settings in the Testing server definition:

Testing server folder: c:/xampp/htdocs/scarabMotorsports

URL prefix: http://localhost/scarabMotorsports

To use links relative to the site root, you need to set up a virtual host. There's a tutorial for creating virtual hosts in Apache on Windows on my site. It wasn't written for xampp, but it should be easy to adapt the instructions.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines