Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paths are working on localhost but not on server

Tags:

path

php

enter image description here

This is structure I have. Page add-product.php is in folder public_html. Partial page ConnectQuery.php I need to access is in folder partial. My project worked fine on localhost with wamp. Now I uploaded it to server and pathing got screwed. Error I get:

Warning: include(/storage/ssd3/728/17657728/public_html/partial/ConnectQuery.php): failed to open stream: No such file or directory in /storage/ssd3/728/17657728/public_html/add-product.php on line 13

Line 13 in add-product.php is

include __DIR__ . "/partial/ConnectQuery.php";

EDIT: There is one more error

Warning: include(): Failed opening '/storage/ssd4/729/17661729/public_html/partial/ConnectQuery.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /storage/ssd4/729/17661729/public_html/add-product.php on line 13
like image 295
Raskoljnikovic Avatar asked Dec 18 '25 16:12

Raskoljnikovic


1 Answers

usually paths never work the same way unless the development machine and server OS are same and they handle directories and files the same way -

Say if your development machine is Windows your Drive C:// will be there its not the same in case of Linux and most of the servers are on linux and hence you're facing paths issue try using a path library in your case

in Node js there is path ; which will point to current directory from you're running your project and from there on the paths will work with no issues .

like image 58
Vicky Yadav Avatar answered Dec 21 '25 06:12

Vicky Yadav