PHP mkdir() Invalid Path
Asked Answered
D

2

6

I'm trying to save files on my server, and as a prerequisite, create directories that don't exist.

I am running a script, dl.php, at /home/public_html/www3/scripts/dl.php:

$request['savedir'] = '/home/public_html/www3/scripts/images/logs';
if( !is_dir($request['savedir']) )
    mkdir($request['savedir']);

And I get:

Warning: mkdir(): Invalid path in /home/public_html/www3/scripts/dl.php

The "images" does exist.

Distemper answered 7/2, 2016 at 20:54 Comment(9)
are you running the script via another php script called in a browser (basically by Apache) or on the server command line as root or another user?Hulsey
I'm running the script directly at the moment, but in production it will be run by a a jQuery Ajax post call.Distemper
Wait , didn't read that completely. it's being called by the browser directly, sorryDistemper
I just forgot to type it here, it's there on the script, just checked.Distemper
I am assuming missing $ is just a typo since the error doesn't complain about it but I am more thinking about user privileges on the folders. Those must be "apache" group and user to be written by Apache (meaning when it works as web application via browser).Hulsey
@Mat the images folder does exist. It shouldn't need to be recursive.Distemper
Did you check your "images" folder user and group and permissions? They are all ok?Hulsey
@Hulsey Just did, turns out in creation of the folder, it had wrong permissions. I changed them to 700, and it's working. Thanks! Please make this an answer.Distemper
Glad to hear it helps.Hulsey
H
3

Please check your "images" folder owner and permissions. It requires to be write enabled to be used with "apache" user/group when it is executed in browser. The error is actually about "permissions" since it is not visible to "apache" user.

Hulsey answered 7/2, 2016 at 21:13 Comment(0)
A
19
  1. Open the config.php on application/config folder
  2. Browse all the way down to the $config['sess_save_path'] = NULL; line.
  3. Change the NULL value to BASEPATH.'sessions'
Aroid answered 28/5, 2019 at 8:5 Comment(0)
H
3

Please check your "images" folder owner and permissions. It requires to be write enabled to be used with "apache" user/group when it is executed in browser. The error is actually about "permissions" since it is not visible to "apache" user.

Hulsey answered 7/2, 2016 at 21:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.