PHP script not running when called upon


#1

I’ve got this code in my WordPress page post.

[code]

Choose a file to upload:

[/code]

And I’ve got the script uploader.php in the proper folder to be executed. This script tested perfectly on my Bluehost account, my Dreamhost VPS account and another Dreamhost shared account.

But now I’m helping someone with a new shared accout for a non-profit (the other shared is a non-profit too). So it’s a standard shared account and this script won’t work.

When I hit the ‘Upload File’ button it ends up downloading the php script instead of executing it. I even set the script to 777 and it still doesn’t work. I tried renaming the script’s extension and in the code above to .pcgi and when I do that the script itself displays on screen instead of uploading the file.

The php script looks like (page name is upload as can be seen in code):

[code]<?php
/* Where the file is going to be placed */
$target_path = “…/sked/”;

/* Add the original filename to our target path.
Result is “…/sked/filename.extension” */
$target_path = $target_path . basename( $_FILES[‘uploadedfile’][‘name’]);

if(move_uploaded_file($_FILES[‘uploadedfile’][‘tmp_name’], $target_path)) {

/* Success Message */
echo “”;
echo “Sked Upload Result”;
echo “

”;
echo “The file “. basename( $_FILES[‘uploadedfile’][‘name’]).
has been successfuly uploaded”;
echo “

<a href=”/upload/">Upload another file";
echo “”;
echo “”;

/* Failure Message */
} else{
echo “”;
echo “Sked Upload Result”;
echo “

”;
echo “There was an error uploading the file, please try again!”;
echo “

<a href=”/upload/">Upload another file";
echo “”;
echo “”;

}
?>[/code]


#2

On all new WordPress installs, the wp-content directory is intentionally set to not allow PHP scripts to run from it. This prevents some common backdoors from operating.

If you need your script to run, we recommend that you put it in another directory. If that isn’t an option, you can also disable the protection on wp-content by removing the .htaccess file in that directory. We don’t recommend that you do that, though!


#3

Excellent! I moved the directory and it works. Mahalo!
Baron