Billed Upload i PHP
Hej eksperter,Jeg har oprettet en php billed-upload formular på min hjemmeside. http://www.psykogeografika.dk/upload.php
Den fungerer ganske glimrende, men lader et par ting tilbage at ønske:
1. Hvordan får jeg den til at melde tilbage til brugeren når billedet er uploadet? F.eks med sætningen "picture uploaded succesfully".
2. Hvordan får jeg den til at kunne modtage filer på op til 5 Mgb?
Koden er som følger:
<?
//print_r($_POST);
if($_POST["action"] == "Upload Image")
{
unset($imagename);
if(!isset($_FILES) && isset($HTTP_POST_FILES))
$_FILES = $HTTP_POST_FILES;
if(!isset($_FILES['image_file']))
$error["image_file"] = "An image was not found.";
$imagename = basename($_FILES['image_file']['name']);
//echo $imagename;
if(empty($imagename))
$error["imagename"] = "The name of the image was not found.";
if(empty($error))
{
$newimage = "images/" . $imagename;
//echo $newimage;
$result = @move_uploaded_file($_FILES['image_file']['tmp_name'], $newimage);
if(empty($result))
$error["result"] = "There was an error moving the uploaded file.";
}
}
?>
<body style="background-image: url(http://www.psykogeografika.dk/backgroundimage.jpg); opacity: 0.9; color: white;
margin-left: 20px;">
<form method="POST" enctype="multipart/form-data" name="image_upload_form" action="<?$_SERVER["PHP_SELF"];?>">
<p><input type="file" name="image_file" size="20"></p>
<p><input type="submit" value="Upload Image" name="action"></p>
</form>
<?
if(is_array($error))
{
while(list($key, $val) = each($error))
{
echo $val;
echo "<br>\n";
}
}
?>