Upload Image With PHP 2 - php Form

Author Topic: Upload Image With PHP 2  (Read 827 times)

Offline alex

  • Global Moderator
  • *****
  • Posts: 77
  • Karma: +19/-0
    • View Profile
Upload Image With PHP 2
« on: May 10, 2010, 04:54:10 AM »


Code: [Select]
<?php
if(isset($_POST['Submit']))
{
$current_image=$_FILES['image']['name'];
$extension substr(strrchr($current_image'.'), 1);
if ((
$extension!= "jpg") && ($extension != "jpeg"
&& (
$extension != "gif")
&& (
$extension != "png"))  
{
die(
'Unknown extension');
}
$time date("fYhis");
$new_image $time "." $extension;
$destination="uploads/".$new_image;
$action copy($_FILES['image']['tmp_name'], $destination);
if (!
$action
{
die(
'File copy failed');
}else{
echo 
"File copy successful";
}
}else{
?>

<form method="post" enctype="multipart/form-data" action="submit.php">
<input type="file" name="image" ><br>
<input type="submit" name="Submit" value="submit">
</form>
<?php
}
?>