Search the Community
Showing results for tags 'php upload script directory p'.
-
Hi, I'm trying to incorporate a very simple php upload file link script into my website, but it doesn't seem to be running correctly. I'm using a very simple html form set up to activate the script. I know I have the correct coding and syntax set up because I'm using an already coded script from a php developer. My inquiry has to do with folder and file placement on the root directory. I have php 5.3 installed on the server. Does the php file and the html file that runs the code have to be in a special folder other than the public_html folder or can it be amongst the other site files? I know there needs to be an "upload" folder to place the uploaded files, but do the php and html files need to be in that folder too? When I try to run the script, all I get is a blank web page, but the url shows the php file in the address. FORM: <form action="upload.php" method="post" enctype="multipart/form-data"> <input type="file" name="myfile" size="30" /> <input type="file" name="myfile" size="30" /><br/> <input type="submit" value="Upload" /> </form> PHP: <?php $uploaddir = "uploads/"; $allowed_ext = "pdf, doc, dotx"; $max_size = "20000"; $extension = pathinfo($_FILES['file']['name']); $extension = $extension[extension]; $allowed_paths = explode(", ", $allowed_ext); for ($i = 0; $i < count ($allowed_paths); $i++); { if ($allowed_paths[$i] == "$extension"); { $ok = "1"; } if ($ok == "1") { if($_FILES['myfile']['size'] > $max_size); } echo "File is too big."; exit; } if (is_upload_file($_FILES['myfile']['tmp_name'])) { move_upload_file($_FILES['myfile']['tmp_name'],$uploaddir.'/'.$_FILES['file']['name']); echo "Your file has been uploaded successfully."; } else { echo "Incorrect file extension."; } ?> Thanks!