Jump to content

Recommended Posts

I got upload script that working fine, but I wonder if anybody have any clue why upload only works with this path

$filename = "../slike/".$image_name;
$filename1 = "../slike/thumbnails/".$image_name;

but not with this

$filename = "/slike/".$image_name;
$filename1 = "/slike/thumbnails/".$image_name;

Confirmation img preview works fine with this

echo '<br /><img src="/slike/thumbnails/'.$filename4.'"><br />';

on same php page.

 

This is less a problem, more wonna know why!" :)

Link to comment
https://forums.phpfreaks.com/topic/240929-image-upload-full-path/
Share on other sites

Remember that / represents the root of your server, not your 'htdocs' root...

So when you write '/slike/bob.jpg', it's actually C:/slike/bob.jpg on windows, not too sure about Linux but it should be similar..

Which you may be confusing for example C:/server/htdocs/slike/bob.jpg...

 

Hope that helps.

The first two code examples you posted are file system paths, being used by php functions that operate on files on the server. The first code is using a file system path relative to the main php script that is being executed. The second code is using an absolute file system path, that starts at the root of the current hard disk. If you want to make an absolute file system path that refers to a folder within your document root folder, you can use $_SERVER['DOCUMENT_ROOT'] to get the full path on your server to your document root folder, then concatenate the rest of the path onto that value.

 

The last code example you posted is HTML markup that is used by a browser to fetch an image. The src="..." attribute is a URL to where the image can be fetched. A leading / on a URL makes it a domain relative URL. The browser takes the domain of the current page and appends a domain relative URL to it to arrive at a the URL to fetch.

The first two code examples you posted are file system paths, being used by php functions that operate on files on the server. The first code is using a file system path relative to the main php script that is being executed. The second code is using an absolute file system path, that starts at the root of the current hard disk. If you want to make an absolute file system path that refers to a folder within your document root folder, you can use $_SERVER['DOCUMENT_ROOT'] to get the full path on your server to your document root folder, then concatenate the rest of the path onto that value.

 

The last code example you posted is HTML markup that is used by a browser to fetch an image. The src="..." attribute is a URL to where the image can be fetched. A leading / on a URL makes it a domain relative URL. The browser takes the domain of the current page and appends a domain relative URL to it to arrive at a the URL to fetch.

 

Dam your good!  :P

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.