Hieu Nguyen Trung
Hieu Nguyen Trung

Reputation: 1622

PHP uploading error on IIS 7

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

Answers (1)

Linus Kleen
Linus Kleen

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

Related Questions