How to run files from every folder in PHP? - php

I have a main folder project name socialNetwork. In this folder, I have 3 folder name application, database, and view. folder view has 2 folders views and page. These folders have files php. Now if I want to run the file from view folder I have to be inPSC:\PhpstormProject\socialNetwork\> and use php view/page/profile.php. If I run PSC:\PhpstormProject\socialNetwork\view> and use php page/profile.php show me the error Could not open input file: page/profile.php. So what can I do to run files from every folder, because now I can only from the main project folder?

Related

How to path folder outside of projek folder in php controller?

-- Images
-- Project Folder assign in url web (ex : abc.com)
Try to access path file in Images like "/../Images/ABC.png" but the url in web becomes abc.com/Images not assign folder images outside project folder.
So, can someone help how to access the folder images outside?
Just create a folder in codeigniter root directory.
An example: I created a folder called "assets" inside codeigniter & upload a image in this folder. Image name is photo.jpg.
Now you can use in view. So base_url automatically replace with your website url.
Note: Must enter your website base_url in app.php

Configure nginx to use files and folders with the same name

I am taking over a website from a sister company and their site has several places where a folder will have a sub folder and a .php file with the same name. For example, the parts folder will have a store folder that contains several more files and folders but it contains a store.php file as well. nginx is throwing a forbidden error because it thinks the user is trying to list the folder directory but the url /parts/store/ should show the store.php file and still allow the user to go to /parts/store/category/product and should show a product file nested in the parts/store/ sub folders.
One option would be to rename the files you want to be directory index as indes.php if your Nginx configuration allows for that. That in my mind is the simplest solution and is most inline with web standards.

How to access directly to files in application directory in codeigniter

I have a folder in my view inside application directory that contain .js files. I want to load .js files in my view. How can do this?
its not a good practice to put your js files in view folder, make a folder called 'assets' in the root directory alongside 'application' and 'system' put all js code in js folder.
assets
--css
--js
-- images
system
application

How to check folder or directory is available in parent folder in PHP?

I am using XMPP server in windows 7 for executing PHP script.
I have project folder in htdocs which contain my projects PHP script with required bootstrap, CSS and jquery files.
I have three subfolders in the project folder as student, teacher, and admin.
I have one folder as the report in admin.
I am working in student folder, How to create report directory in admin folder if report folder does not exist?
I want to create folder or Director in parent folder's not in the same folder.
If you want to get the parent directory you can use the function dirname. In your example it would look as follows:
$rebuilt_dir = "../admin/report";
$parent_dir = dirname($rebuilt_dir);
if(!is_dir($parent_dir)) {
if(!mkdir($parent_dir))
echo "Error creating dir: ".$!;
if(!is_dir($rebuilt_dir)) {
if(!mkdir($rebuilt_dir))
echo "Error creating dir: ".$!;
}

Uploading a file with PHP and moving it

I have a form where users can upload images. I know how to do it with HTML/PHP and I know that I have to move the temp file to the permanent directory. Well this all works well when my file that processes the form, is in the root directory. But, I would like to have it work within another directory, on the same server.
The Structure is this:
ROOT
>images
>mobile
>upload.php
I would like to have the file put inside images, which is outside of the "mobile" directory.
My current upload path that does not work is:
define('UPLOADPATH', 'images/');
So essentially I need to go back one directory and then into images. How can I do this?
You need to add a .. To move to the parent directory. See this resource for more information

Categories