PDA

View Full Version : A not workin php upload script, need help??


ice-o
February 26th, 2005, 07:23 PM
The script just doesn't work, i want the files to be uploaded to the folder i have givven in the variable, but i keep on getting the message: The folder = is not /home/eisokant/public_html/websystem/uploads/ writable, what can i do about it!!


/*adminuploadfile.php - the script*/

<?php

$filename=$_POST['file'];
$folder = "/home/eisokant/public_html/websystem/uploads/";


if (is_writable($filename)) {


if (!$upload = fopen($filename, 'a'))
{
echo "Cannot open file ($filename)";
exit;
}

if (fwrite($upload) === FALSE)
{
echo "Cannot write to file ($folder)";
exit;
}

echo "Success, uploaded ($filename) to ($folder)";

fclose($upload);

}
else
{
echo "The folder = $folder is not writable";
}

?>

Spider
February 26th, 2005, 08:20 PM
$folder = "/home/eisokant/public_html/websystem/uploads/";
Where is adminuploadfile.php located?

Chances are it's in public_html, so the path you want in that adminuploadfile.php is
$folder = "websystem/uploads/";

degsy
February 26th, 2005, 08:36 PM
Welcome :)

Where did you get this script from?

You want to be using copy() or move_uploaded_file()

Checkout here for an upload script
http://www.zachwhite.com/scripts.htm

Sinister-wolf
March 1st, 2005, 05:05 PM
Chmod your folder you want so its writable as well, using your favorite FTP programusually something like 777 is what it'll end up being.

Steven.Bentley
March 2nd, 2005, 07:05 PM
Rather than chmod 777 I would chgrp the directory to the group Apache runs as (see phpinfo() to find out what it is) then chmod it 755. That was only you and Apache can write, other people with accounts on the same server can't (although they could via a script similar to yours)