afridy
December 7, 2018, 3:38am
1
HI Folks,
include (realpath(__DIR__ . '/../../../..') . "/includes/session_start.php");
This works perfectly
<link href=\"" . realpath(__DIR__ . '/../../../..') . "/content/dashboard/bower_components/font-awesome/css/font-awesome.min.css\"
This does not work dispite correct path. console shows 404 not found.
pls advise.
So what does the console show as the path it is looking for your file in?
1 Like
afridy
December 7, 2018, 3:53am
3
Try removing the trailing backslash.
<link href=\"" . realpath(__DIR__ . '/../../../..') . "/content/dashboard/bower_components/font-awesome/css/font-awesome.min.css\"
1 Like
afridy
December 7, 2018, 4:02am
6
bootstrap.min.css\"
if i remove the backslash above, then php error.
afridy
December 7, 2018, 4:07am
7
finally if i run the following console path which shows 404
http://example.com/home/accessto/public_html/demo3/admin/content/dashboard/bower_components/bootstrap/dist/css/bootstrap.min.css
in this way, it works in the browser.
http://example.com/demo3/admin/content/dashboard/bower_components/bootstrap/dist/css/bootstrap.min.css
that mean removing this part
home/accessto/public_html/
Please supply more script because it appears HTML and PHP scripting are not being used correctly.
<link href=\"" . realpath(__DIR__ . '/../../../..') . "/content/dashboard/bower_components/font-awesome/css/font-awesome.min.css\"
What I would do is break the script down and test to ensure each line works correctly. Afterwards I may concatenate the lines.
<?php
/*
<link href=\"" . realpath(__DIR__ . '/../../../..') . "/content/dashboard/bower_components/font-awesome/css/font-awesome.min.css\"
*/
// NOTICE THE TRAILING BACKSLASH IS REMOVED
$tmp = realpath(__DIR__ . '/../../../..')
. "/content/dashboard/bower_components/font-awesome/css/font-awesome.min.css" ;
if( file_exists($tmp) ):
echo '<link href="' . $tmp .'">';
else:
echo 'Problem with path ===> ' .$tmp;
die;
endif;
Edit:
Spelling not my forty
1 Like
Try this and see if the path works perfectly :
<?php
$tmp = realpath(__DIR__ . '/../../../..') . "/includes/session_start.php";
if( file_exists($tmp) ):
echo 'Path OK ==> ' .$tmp;
else:
echo 'Problem with path ===> ' .$tmp;
die;
endif;
1 Like
afridy
December 7, 2018, 4:36am
11
so i admit that there is a problem in the path, if i correct it by removing one extra /β¦
from dir , then it works
Path OK ==> /home/accessto/public_html/demo3/admin/content/dashboard/bower_components/font-awesome/css/font-awesome.min.css
now let me put this in to the script and seeβ¦
1 Like
afridy
December 7, 2018, 4:50am
12
Thank you john
problem resolved !!! Great Help. Thanks every oneβ¦
$tmp= realpath(__DIR__ . '/../../..')
. "/content/dashboard/bower_components/bootstrap/dist/css/bootstrap.min.css" ;
echo "
<link href=\"" . $tmp . "\" rel=\"stylesheet\">
1 Like
afridy
December 7, 2018, 5:27am
13
Well , it is emberessing, i had to open the thread again coz i made a mistake. there is some problem still which i did not noticed earlier. sorry about it.
This works fine :
$tmp = realpath(__DIR__ . '/../../..')
. "/content/dashboard/bower_components/bootstrap/dist/css/bootstrap.min.css";
if( file_exists($tmp) ):
echo 'Path OK ==> ' .$tmp;
else:
echo 'Problem with path ===> ' .$tmp;
die;
endif;
Path OK ==> /home/accessto/public_html/demo3/admin/content/dashboard/bower_components/bootstrap/dist/css/bootstrap.min.css
but this does not
$tmp= realpath(__DIR__ . '/../../..')
. "/content/dashboard/bower_components/bootstrap/dist/css/bootstrap.min.css" ;
echo "<link href='" . $tmp ."' rel=\"stylesheet\">";
error :
GET http://example.com/home/accessto/public_html/demo3/admin/content/dashboard/bower_components/bootstrap/dist/css/bootstrap.min.css net::ERR_ABORTED 404 (Not Found)
Try using the PHP if( file_exits($tmp) ) ):
afridy
December 7, 2018, 6:01am
15
yah it says file exist, but when included it in href as below it gives 404.
echo "<link href='" . $tmp ."' rel=\"stylesheet\">";
afridy
December 7, 2018, 6:18am
16
i will go ahead with relative path inside href.
Try adding these lines to the beginning of your webpage:
<?php
// PHP7 specific, fails fast, this file only
declare(strict_types=1);
// this file and all included/required files
error_reporting(-1);
ini_set('display_errors', 'true');
$tmp= realpath(__DIR__ . '/../../..')
. "/content/dashboard/bower_components/bootstrap/dist/css/bootstrap.min.css" ;
echo '<br><br> filesize($tmp) ==> ',
filesize($tmp);
$tmp2 = file_get_contents($tmp);
echo '<br><br> strlen($tmp2) ==> ',
strlen($tmp2);
echo '<br><br> print_r($tmp2) ==> ',
print_r( $tmp2 );
die;
afridy
December 7, 2018, 8:14am
18
Hi johan, for you code this is the out put
filesize($tmp) ==> 113498
strlen($tmp2) ==> 113498
print_r($tmp2) ==> /*! * Bootstrap v3.3.1 (http://getbootstrap.com) * Copyright 2011-2014 Twitter, Inc. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) *//*! normalize.css v3.0.2 | MIT License | git.io/normalize */html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}dfn{font-style:italic}h1{margin:.67em 0;font-size:2em}mark{color:#000;background:#ff0}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{height:0;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{margin:0;font:inherit;color:inherit}button{overflow:visible}button,select{text-transform:none}button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}input{line-height:normal}input[type=checkbox],input[type=radio]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:0}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{height:auto}input[type=search]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}fieldset{padding:.35em .625em .75em;margin:0 2px;border:1px solid silver}legend{padding:0;border:0}textarea{overflow:auto}optgroup{font-weight:700}table{border-spacing:0;border-collapse:collapse}td,th{padding:0}/*! Source:........
I have made this mistake before, never learned the lesson and no doubt will make exactly the same mistake again
The link is expecting a URL and not a PATH .
2 Likes
afridy
December 7, 2018, 8:55am
20
John_Betong:
<?php
// PHP7 specific, fails fast, this file only
declare(strict_types=1);
// this file and all included/required files
error_reporting(-1);
ini_set('display_errors', 'true');
$tmp= realpath(__DIR__ . '/../../..')
. "/content/dashboard/bower_components/bootstrap/dist/css/bootstrap.min.css" ;
echo '<br><br> filesize($tmp) ==> ',
filesize($tmp);
$tmp2 = file_get_contents($tmp);
echo '<br><br> strlen($tmp2) ==> ',
strlen($tmp2);
echo '<br><br> print_r($tmp2) ==> ',
print_r( $tmp2 );
die;
I will remember this john
1 Like