Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

Upload script

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
SpaceshipSpaceship
Watch
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:
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
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
does the /upload_dir directory exist where it should be on the server?
 
0
Close
yea that was the problem:) i just had to change it to "upload_dir/" from "/upload_dir"
 
0
Close
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back