HomeSunday, June 24, 2018, 01:37:03
1

Upload File with PHP

Tuesday, February 10, 15, 13:27:18, 3 Yaers Ago Via wain, Hits: 6709
Basic file uploading with PHP
Example:

Code:
<?php
if(isset($_POST['Submit']))
{
$current_file=$_FILES['file']['name'];
$extension = substr(strrchr($current_file, '.'), 1);
if (($extension!= "txt") && ($extension != "zip"))
{
die('Unknown extension');
}
$time = date("fYhis");
$new_file = $time . "." . $extension;
$destination="uploads/".$new_file;
$action = copy($_FILES['file']['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="file" ><br />
<input type="submit" name="Submit" value="submit">
</form>
<?php
}
?>

Sign In

Sponsor
Related

PHP filesize

The filesize function returns the size of the specified file.

MySQL to RSS

Publishing MySQL data in RSS

PHP Cookies - setcookie

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

Timed Redirect JavaScript

Timed redirect javaScript/PHP example

Show / Hide Div with CSS

CSS Display and Visibility:The visibility property specifies whether or not an element is visible.

Create dynamic Web Pages with PHP & MySQL

Create dynamic Web Pages with PHP & MySQL, Requirement(s): PHP Server, MySQL

PHP Form Basic

PHP Form - PHP form basic, Requirement(s): PHP Server

Link Base 2.0.

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 Cookies and Sessions Tutorial

PHP Cookies and Sessions Tutorials

Block Visitors From Specific IP Address

Learn How To Restrict Users From Different IP Addresses.
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.