Ad block is installed and active. Please support us by disabling it.
HomeThursday, September 21, 2017, 03:15:09
1

Upload Image with PHP [Example2]

Monday, February 9, 15, 01:07:57, 3 Yaers Ago Via wain, Hits: 2622
[Example2] Tutorial - How to upload and resize image with PHP
submit.php

Code:
<?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
}
?>

KevinTheProGuy Sunday, April 24, 2011, 10:12:02

THANKS DUDE! HERE MY CODE!
THIS CODE WILL AUTOMATICLY CHANGE EVERY FILE TO .png

if(isset($_POST[\'Submit\']))
{
$current_image=$_FILES[\'image\'][\'name\'];
$extension = substr(strrchr($current_image, \'.\'), 1);

$str1 = str_replace(\"$extension\", \".png\", \"$extension\", $count);

$new_image = $myuser[username].$str1;
$destination=\"images/users/\".$new_image;
$action = copy($_FILES[\'image\'][\'tmp_name\'], $destination);
if (!$action)
{
echo \"Kon foto niet uploaden!\";
}else{
echo \"Foto is geupload.\";
}
}else{
?>






}
?>

vicko Sunday, February 12, 2012, 11:55:57

Thank you guys for the codes!

Sign In

Sponsor

Related

Contact Us PHP Form 1.1.

A contact us form with email and form field validation. It allows your visitors to send you an email directly from your website.

Contact Us 2.0. with HTML Page and Pop Up Frame

This is the same Contact Us 2.0. that is in this forum, But I have added more options to this script and a html page with a very nice pop Up frame that DONT get block by any pop Up software. Many websites use this type of script to bypass the blocking…

Upload Attachment - PHP Tutorial

Upload attachment with PHP example, Requirement(s): PHP server

PHP Date Examples

Returns a string formatted according to the given format string using the given integer timestamp or the current time if no timestamp is given.

Process Form Data with Jquery

jQuery, Process form data

PHP Links Script 1.1.

This script allows you to manage your links using a MySQL database. It features easy install, user submission, and an admin panel to add, edit and remove categories and links. The script is easy to customize to suit your needs.

MySQL Tutorials

MySQL tutorials, MySQL training, learn MySQL, MySQL Tutorial with practical examples.

PHP filesize

The filesize function returns the size of the specified file.

Link Base Pro :: Free Link Index Script

This script allows you to manage your links using a MySQL database. It features easy install, user submission, and an admin panel to add, edit and remove categories and links.

PHP $_GET Function

Get function in PHP
About Author

wain

Date Registered: Sun, Feb 8, 15
Last Time Online: Thu, Jun 15, 17
So far has created 115 entries.
wain
This author has not yet filled in any details.