Reputation: 1622
HI every1, im just new in PHP and here's my problem
I've tried to create a upload tool to manager all the upload file on server I'm using FancyUpload to upload file, and here's my problem:
$baseUrl = '/files/';
if(!is_dir($baseUrl))
mkdir($baseUrl, 0777);
$filepath = $baseUrl . $_FILES['photoupload']['name'];
move_uploaded_file($_FILES['photoupload']['tmp_name'], $filepath);
chmod($baseUrl.$_FILES['photoupload']['name'], 0777);
The problem is that i want to upload to folder 'files' at the root of my project but it always upload file to my E:\files\ while my project is located in E:\My Works\UploadTool\
Can any help plzzzz?
Upvotes: 0
Views: 426
Reputation: 34612
$filepath = $_SERVER['DOCUMENT_ROOT']
. DIRECTORY_SEPARATOR
. $_FILES['photoupload']['name'];
Whereas $_SERVER['DOCUMENT_ROOT']
contains the absolute path of your "project" and DIRECTORY_SEPARATOR
is a constant you should use when using WAMPP for development and LAMP for deployment.
Upvotes: 1