Cant upload file to protected directory php script
Hihi , i ve pick this simple php script out from somewhere. i ve managed to get it working under the root directory , but when i moved it to a protected directory , the script just falls flat with this message
Quote: Warning: move_uploaded_file(http://www.mysite.co.uk/files/Abstract(TT).jpg): failed to open stream: HTTP wrapper does not support writeable connections. in /home/mysite/public_html/files/uploader.php on line 19
What im trying to do is to have a protected directory where certain people can enter this folder and access this upload form and upload thier PDF file into this same directory.
can anybody please help me.
<?php
//Define some variables
$dir = \"../files/\"; //I have the files uplaoded to this directory
//MIME types to allow, Gif, jpeg, zip
$types = array(\"image/gif\",\"image/pjpeg\",\"application/x-zip-compressed\",\"application/pdf\",\"application/msword\");
//Check to determine if the submit button has been pressed
if(isset($_POST['submit'])){
//Shorten Variables
$tmp_name = $_FILES['upload']['tmp_name'];
$new_name = $_FILES['upload']['name'];
//Check MIME Type
if (in_array($_FILES['upload']['type'], $types)){
//Move file from tmp dir to new location
move_uploaded_file($tmp_name,$dir . $new_name);
echo \" was uploaded sucessfully!\";
}else{
//Print Error Message
echo \"<small>File <strong><em></em></strong> Was Not Uploaded!</small><br />\";
//Debug
$name = $_FILES['upload']['name'];
$type = $_FILES['upload']['type'];
$size = $_FILES['upload']['size'];
$tmp = $_FILES['upload']['name'];
echo \"Name: $name<br/ >Type: $type<br />Size: $size<br />Tmp: $tmp\";
}
}
else{
echo 'Could Not Upload Files';
}
<form action=\" echo $_SERVER['PHP_SELF']; \" method=\"post\" enctype=\"multipart/form-data\">
<fieldset>
<legend>Upload Files</legend>
<input type=\"file\" name=\"upload\" />
</fieldset>
<input type=\"submit\" name=\"submit\" value=\"Upload Files\" />
</form>
?>
starter posted this at 02:06 — 29th July 2004.
They have: 80 posts
Joined: Feb 2003
Soooorry, somehow it decided to work after all , argghhh
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.