stiriprogramareimaginifav

Blog > PHP > Functie si formular de incarcare imagine in PHP

Articole recente

  • HTML5_Logo_512
    Cod HTML: Adauga ca

    <a href=":Add This Page To Your Favorites!" onDragstart="return... 

  • javascript
    Descopera ce fel de

    NSString *deviceType = [UIDevice currentDevice].model; if([deviceType isEqualToString:@"iPhone"]) //... 

  • mysql
    Exporta fiecare tabe

    mysql -e 'show databases' | sed -n '2,$p' | xargs -I DB 'mysqldump DB > DB.sql'  

  • php_logo_128
    Functie si formular

    <!-- Form Area --> <form action="uploader.php" method="post"... 

Functie si formular de incarcare imagine in PHP

0
<!-- Form Area -->

<form action="uploader.php" method="post" enctype="multipart/form-data">Select Image: <input type="file" name="userfile" />
<input type="submit" value="Upload!" /></form>&nbsp;

<!--?php  # Variables $path = "images/";   $max_size = "200000";  # File $filename = $_POST['userfile'];  # Control if (!isset($HTTP_POST_FILES['userfile'])) exit;  if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) {  if ($HTTP_POST_FILES['userfile']['size']-->$max_size) {
echo "The File is Too Big. The Max File Size is $max_size KB
n";
exit;
}

# Type Control
if (
($HTTP_POST_FILES['userfile']['type']=="image/gif") ||
($HTTP_POST_FILES['userfile']['type']=="image/jpg") ||
($HTTP_POST_FILES['userfile']['type']=="image/bmp") ||
($HTTP_POST_FILES['userfile']['type']=="image/png") ||
($HTTP_POST_FILES['userfile']['type']=="image/jpeg")
)
{

# If File Exist
if (file_exists($path . $HTTP_POST_FILES['userfile']['name']))
{
echo "A File With That Name Already Exists!
";
exit;
}

$res = copy($HTTP_POST_FILES['userfile']['tmp_name'], $path .

$HTTP_POST_FILES['userfile']['name']);
if (!$res){
echo "Upload Failed!
";
exit;
}
else{
echo "Upload Sucessful!
";
}

echo "File Name: ".$HTTP_POST_FILES['userfile']['name']."
";
echo "File Size: ".$HTTP_POST_FILES['userfile']['size']." bytes
";
echo "File Type: ".$HTTP_POST_FILES['userfile']['type']."
";
echo "<a href="$path&quot;.$HTTP_POST_FILES['userfile']['name'].&quot;">View Image</a>";
}
else
{
echo "Wrong File Type
";
exit;
}
}

?&gt;

No related posts.




No related posts.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>