- Impact
- 19
Hey
I am reading an ebook on PHP and they had this example: i modified it a bit and it doesnt work..can anyone tell me whats wrong? it doesnt give any error but it doesnt upload anything either:
aight nvm i got it..it was a enctype typo
but i get this error now:
I am reading an ebook on PHP and they had this example: i modified it a bit and it doesnt work..can anyone tell me whats wrong? it doesnt give any error but it doesnt upload anything either:
PHP:
<?php
$version = "0.001"; // Version
$title = "Upload $version"; // Site Title
if ($_POST['submit']) {
$file_dir = "/upload_dir";
foreach($_FILES as $file_name => $file_array) {
echo "path: ".$file_array['tmp_name']."<br />\n"; #File Temporery name
echo "name: ".$file_array['name']."<br />\n"; #File Name
echo "type: ".$file_array['type']."<br />\n"; #File Type
echo "Size: ".$file_array['size']."<br />\n"; #File Size
if(is_uploaded_file($file_array['tmp_name'])) {
move_uploaded_file($file_array['tmp_name'], "$file_dir/$file_array[name]") or die ("Couldn't copy");
echo "file was moved!<br /><br />";
}
}
}
?>
<html>
<head>
<title><?=$title ?></title>
</head>
<body>
<form action ="?" encyupe="multipart/form-data" method="POST"> <!--Form-->
<input type="hidden" name="MAX_FILE_SIZE" value="1048576" / >
<p>File to Upload:<input type="file" name="fileupload" / ></p>
<p><input type ="submit" name="submit" value="Upload!" / ></p>
</form>
</body>
</html>
aight nvm i got it..it was a enctype typo
but i get this error now:
Code:
Warning: move_uploaded_file(/upload_dir/400px-Rcdtank.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\Program Files\xampp\htdocs\uploadscript\upload.php on line 16
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\Program Files\xampp\tmp\php11D.tmp' to '/upload_dir/400px-Rcdtank.jpg' in C:\Program Files\xampp\htdocs\uploadscript\upload.php on line 16
Couldn't copy






