English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I recently upgraded to a dedicated hosting package and am suffering a little on the learning curve with the following script which worked previously on a shared hosting package. I think it's a problem with granting file permission. Here's the code that processes a file upload ...

if (file_exists($target_path ) == FALSE) {
$result_var = mkdir($target_path, 0777);
}

$target_name = $target_path . "/" . $file_name . ".jpg";
$target_path .= "/" . basename( $_FILES['uploadedfile'] ['name'] );

if(move_uploaded_file( $_FILES[ 'uploadedfile' ]
['tmp_name'], $target_path ) == FALSE) {
return "Error uploading file!";
}

I have no problem creating the new directory, I'm only having a problem with move_upload_file.
So basically I keep getting the "Error uploading file" errors.

Any ideas??? Also, should I be using 0777?

2007-05-18 06:01:15 · 2 answers · asked by caweiten 1 in Computers & Internet Programming & Design

The problem was related to safe mode being off. Once I changed the local and master values of safe mode, it worked.

2007-05-18 12:46:57 · update #1

I changed the file permission to 0755, that seems to still work, thanks!

2007-05-19 07:34:02 · update #2

2 answers

Glad you found the safe mode issue.. I would not leave those files 777 (the world can write to that execute within and trust me they will) Set them to 755 you may have to make the webserver the owner of that directory but that is much safer.

2007-05-18 16:40:14 · answer #1 · answered by Tracy L 7 · 0 0

It seems to me that the directory that you are trying to write to is not writeable. That is why you are getting the error when uploading file message. CHMOD that directory to 0777 or 777 it should work fine afterwards.

2007-05-18 06:06:10 · answer #2 · answered by DefiantRican 3 · 0 0

fedest.com, questions and answers