Originally Posted by
uamusa
Trying to implement and Upload form on my Web Server:
upload.hmtl :
<form enctype="multipart/form-data" action="upload.php" method="POST">
Please choose a file: <input name="uploaded" type="file" /><br />
<input type="submit" value="Upload" />
</form>
upload.php :
<?php
$currentdir = getcwd();
$target = $currentdir . "/upload/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
echo "Temp Location: $target_path<br>";
$temploc=$_FILES['uploadedfile']['tmp_name'];
echo "Temploc: $temploc<br>";
$ok=1;
//This is our size condition
if ($uploaded_size > 350000)
{
echo "Your file is too large.<br>";
$ok=0;
}
//This is our limit file type condition
if ($uploaded_type =="text/php")
{
echo "No PHP files<br>";
$ok=0;
}
//Here we check that $ok was not set to 0 by an error
if ($ok==0)
{
Echo "Sorry your file was not uploaded";
}
//If everything is ok we try to upload it
else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) //THIS IS LINE 43
{
echo "The file ".
basename( $_FILES['uploadedfile']['name']). " has been uploaded";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}
?>
What you get when you attempt to use the upload form :
Warning: move_uploaded_file(/home/chris/public_html/upload/Caleb.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/chris/public_html/upload.php on line 43
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpoWCXpD' to '/home/chris/public_html/upload/Caleb.jpg' in /home/chris/public_html/upload.php on line 43
Sorry, there was a problem uploading your file.
Any ideas????
did you solve that ?? I 'm working to understand php at w3schools. when i tried thisexample, i took similar message as yours which you seeing below:
Code:
Warning: move_uploaded_file(transpix.gif) [function.move-uploaded-file]: failed to open stream: Permission denied in /var/www/yeni/index.php on line 234
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpNwcYNk' to 'transpix.gif' in /var/www/yeni/index.php on line 234
Stored in: transpix.gif
/var/www/yeni directory and sub directories are chmod 777.