I am tryinh to use a simple upload script in my web .. but i have no idea why its not working .. i am always getting the "Couldn't copy the file" MSG .. i did chmod 777 for testDir .. note that testDir is under the public_html directory and the script is under the public_html .. please advice .. and thank you 🙂 any help will be highly appreciate it 🙂
up.htm File
<html>
<head>
<title>Upload a File</title>
</head>
<body>
<h1>Upload a File</h1>
<form enctype="multipart/form-data" method="post" action="up2.php">
<p><strong>File to Upload:</strong><br>
<input type="file" name="img1" size="30"></p>
<P><input type="submit" name="submit" value="Upload File"></p>
</form>
</body>
</html>
up2.php File
<?
if ($_FILES['img1'] != "") {
copy($_FILES['img1']['tmp_name'], "testDir/".$_FILES['img1']['name'])
or die("Couldn't copy the file!");
} else {
die("No input file specified");
}
?>
<html>
<head>
<title>Successful File Upload!</title>
<body>
<h1>Success!</h1>
<P>You sent: <? echo $FILES['img1']['name'] ?>, a <? echo $FILES['img1']['size'];
?> byte file with a mime type of <? echo $_FILES['img1']['type']; ?>.</p>
</body>
</html>