Falco1199
01-06-2003, 09:37 PM
A friend gave me an uploading script, something like this:
<?
// $userfile is where file went on webserver
// $userfile_name is original file name
// $userfile_size is size in bytes
// $userfile_type is mime type e.g. image/gif
echo "Variables are:<br />";
echo $userfile." ".$userfile_name." ".$userfile_size." ".$userfile_type."<br /><br />";
if ($userfile=="none")
{
echo "Problem: no file uploaded";
exit;
}
if ($userfile_size==0)
{
echo "Problem: uploaded file is zero length";
exit;
}
$upfile = "../Media/Images/".$userfile_name;
if (!copy($userfile, $upfile))
{
echo "Problem: Could not move file into directory";
exit;
}
echo "<center><a href='../Media/Images/".$userfile_name."'>View Your Image</a></center><br />";
echo "Preview of uploaded file contents:<br><hr>";
echo $contents;
echo "<br><hr>";
?>
And the page linking to it has enctype="multipart/form-data" as a form attribute.
It seemed as if it would work nicely, but there is a permissions problem, giving me this error:
Warning: Unable to create '../Media/Images/testpicture.jpg': Permission denied in /path/imageup.php on line 34
Problem: Could not move file into directory
The "Problem" thing is from the script. Also, note that the lines aren't correct, though that should matter.
Does anyone know how I should change the permissions for this to work?
<?
// $userfile is where file went on webserver
// $userfile_name is original file name
// $userfile_size is size in bytes
// $userfile_type is mime type e.g. image/gif
echo "Variables are:<br />";
echo $userfile." ".$userfile_name." ".$userfile_size." ".$userfile_type."<br /><br />";
if ($userfile=="none")
{
echo "Problem: no file uploaded";
exit;
}
if ($userfile_size==0)
{
echo "Problem: uploaded file is zero length";
exit;
}
$upfile = "../Media/Images/".$userfile_name;
if (!copy($userfile, $upfile))
{
echo "Problem: Could not move file into directory";
exit;
}
echo "<center><a href='../Media/Images/".$userfile_name."'>View Your Image</a></center><br />";
echo "Preview of uploaded file contents:<br><hr>";
echo $contents;
echo "<br><hr>";
?>
And the page linking to it has enctype="multipart/form-data" as a form attribute.
It seemed as if it would work nicely, but there is a permissions problem, giving me this error:
Warning: Unable to create '../Media/Images/testpicture.jpg': Permission denied in /path/imageup.php on line 34
Problem: Could not move file into directory
The "Problem" thing is from the script. Also, note that the lines aren't correct, though that should matter.
Does anyone know how I should change the permissions for this to work?
