Ad block is installed and active. Please support us by disabling it.
HomeSunday, November 19, 2017, 14:12:25
1

Upload Image with PHP [Example2]

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

imagecreate() returns an image identifier representing a blank image of specified size.

Send This Link PHP Script

A popup form which allows your visitors to send a referral link from your site. It features admin notification and HTML output.

Bookmark Script

Allow your users to easily bookmark your site, by clicking on a link on the page.

PHP $_SESSION

Session_start creates a session or resumes the current one based on a session identifier passed via a GET or POST request, or passed via a cookie.

Sending HTML Email With Images - PHP Tutorial

Sending HTML Email With Images - Upload Image with PHP - Creating Dynamic Webpages Using PHP and MySQL - Select, Delete, Update..

PHP Write to File

PHP Write to File :: PHP Tutorial, 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.

PHP Tutorials

Useful step-by-step PHP tutorials for beginners

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.

Smarty - Create dynamic Web Pages with PHP & MySQL

Creating Dynamic Web Pages Using Smarty and MySQL - Requirement(s): PHP Server, MySQL
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.