Ad block is installed and active. Please support us by disabling it.
HomeWednesday, April 25, 2018, 08:53:45
1

Upload Image with PHP [Example2]

Monday, February 9, 15, 01:07:57, 3 Yaers Ago Via wain, Hits: 5846
[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

PHP $_GET Function

Get function in PHP

RSS, MySQL & Smarty

Smarty > Publishing MySQL Data in RSS 2.0

Syntax highlighting in Smarty

Syntax highlighting for Smarty - Google Code Prettify

PHPBB3 Shoutbox

Vesion: 1.1. Released: 08/08/10, Licence GNU, Price: Free

PHP Redirect

Header (location) redirect must be processed before any output to the browser.

Adodb Recordcount Example

RecordCount returns the number of rows in the record set.

Password Protect With PHP

Password protect tith PHP - tutorial

PHP Cookies - setcookie

Defines a cookie to be sent along with the rest of the HTTP headers.

Prevent the error loading XML – libxml_use_internal_errors

libxml_use_internal_errors() allows you to disable standard libxml errors and enable user error handling.

Creating a CAPTCHA with PHP with imagecreate

This tutorial will show you how to create a form with Captcha, Requirement(s): PHP Server, GD Graphics Library
About Author

wain

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