Semplice Upload di file
Posted on 12. Jul, 2009 by daniele in script php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php if(isset($_POST['Submit'])){ echo 'The file "'. basename( $_FILES['uploadedfile']['name']). '" has been uploaded!';}else{?>Please Choose a File<?php } ?></title>
</head>
<body>
<?php if(!isset($_POST['Submit'])){?>
<form action="<?=$_SERVER['PHP_SELF'];?>" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="uploadedfile" id="uploadedfile" />
<br />
<input type="submit" name="Submit" value="Submit" />
</form>
<?php
}else{
$path = "uploads/";
$path = $path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
?>
<div style="text-align:center;width:350px;border:1px solid #cccccc;background-color:#f1f1f1;">
"Thanks for your uploaded file!"
</div>
<?php
} else{
echo "There was an error uploading the file, please try again!";
}
}//end if
?>
</body>
</html>





Leave a reply