Upload Image with PHP - php Form

Author Topic: Upload Image with PHP  (Read 2597 times)

Offline admin

  • Administrator
  • *****
  • Posts: 67
  • Karma: +10/-0
  • Gender: Male
    • View Profile
Upload Image with PHP
« on: March 20, 2009, 01:35:13 PM »


Code: [Select]
<?php
if(isset($_POST['Submit']))
{
$current_image=$_FILES['image']['name'];
$extension substr(strrchr($current_image'.'), 1);
if ((
$extension!= "jpg") && ($extension != "jpeg") && ($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
}
?>

:D :D :D
« Last Edit: February 22, 2010, 07:19:49 PM by admin »