0

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?

1 Answer 1

1
$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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.