regoch Posted July 2, 2011 Share Posted July 2, 2011 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!" Quote Link to comment https://forums.phpfreaks.com/topic/240929-image-upload-full-path/ Share on other sites More sharing options...
cs.punk Posted July 2, 2011 Share Posted July 2, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/240929-image-upload-full-path/#findComment-1237567 Share on other sites More sharing options...
PFMaBiSmAd Posted July 2, 2011 Share Posted July 2, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/240929-image-upload-full-path/#findComment-1237579 Share on other sites More sharing options...
regoch Posted July 2, 2011 Author Share Posted July 2, 2011 now things looking clearer! thanks people! Quote Link to comment https://forums.phpfreaks.com/topic/240929-image-upload-full-path/#findComment-1237598 Share on other sites More sharing options...
cs.punk Posted July 3, 2011 Share Posted July 3, 2011 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! Quote Link to comment https://forums.phpfreaks.com/topic/240929-image-upload-full-path/#findComment-1237897 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.