The path to the pictures is recorded in the database. I bring them through the function from different pages located in the root directory and from different level folders.

How to write the address of these pictures in the database? Relative or absolute?

With relative problems there, but only from certain pages. Each time to determine where the request came from and to change the name of the picture is somehow not serious. I register the absolute address of the http://site.ru/forum/arhiv/1.jpg type, but after that the files are not displayed.

  • I do not know if this is correct, but I save "/forum/arhiv/1.jpg" - splash58

2 answers 2

http://site.ru/forum/arhiv/1.jpg

If everyone is in the same folder and are named by ID, then no paths should be stored at all.

  • http://site.ru in the database can not be stored - Alex
  • @Alex, is it worth storing "/ forum / arhiv /"? - vasa_c
  • depends on site structure - Alex

Use as an option: /forum/arhiv/1.jpg or 1.jpg depending on the data storage structure. Absolute paths http://site.ru/forum/arhiv/1.jpg not recommended because for example, when switching to the HTTPS protocol, you will need to edit the entire database.

With relative problems there, but only from certain pages. Each time to determine where the request came from and to change the name of the picture is somehow not serious.

What does it mean to change the name of the picture? Separate the image storage paths from the pages output paths. For example, a page could be http://site.ru/forum/arhiv/1 , and for storing pictures, use the folder http://site.ru/media/ .