Reputation: 9074
I need to upload files on an already existing folder from a php script on my account : www.example.com , on www.exampleuploads.com/uploads , but not able to do it ? Please help.
Also, my script detects that the folder does not exists ( but it actually does exists) , so it goes to mkdir , but mkdir also fails.
I am doing this :
if (directory for uploading does not exists)
{
mkdir( 'http://www.exampleuploads.com/uploads', 0755)
}
Upvotes: 1
Views: 1868
Reputation: 9413
You cant give a url like that , u need to specify the path in ur hosting dir..
eg :
mkdir( $_SERVER["DOCUMENT_ROOT"].'uploads', 0755);
//$_SERVER["DOCUMENT_ROOT"] this will give the path
Find path for http://www.exampleuploads.com in ur hosting server
Upvotes: 2
Reputation: 1161
given path is the your reference path... called visual path its only handle bu the browser
to create directory you have to set the physical path of that server like DOCUMENT_ROOT and your folder path and for other domain you have a permission to create folder on the that server
you can achieve this path using $_SERVER['document_root']
Upvotes: 2
Reputation: 11623
The function mkdir
creates a directory on the server running the PHP script (www.example.com
). If you want to create a directory on that server, you need to put the physical path (relative to the executing script or absolute).
You cannot create a new directory using a URL, even if they are hosted on the same server.
If they are not hosted on the same server, you cannot use mkdir
on one server to create a directory on another server.
Upvotes: 1