HomeMonday, June 18, 2018, 15:28:49
1

Upload Attachment - PHP Tutorial

Tuesday, February 10, 15, 10:33:26, 3 Yaers Ago Via wain, Hits: 7037
Upload attachment with PHP example, Requirement(s): PHP server
Download:
http://phpform.net/download.php?f=attachment.zip

Code:
<?php
if(isset($_POST['query'])) {
@$option = $_POST['option'];
@$attacname = $_POST['attacname'];
if($option == 1) {
$current_file = $_FILES['file']['name'];
$extension = substr(strrchr($current_file,'.'),1);
if(($extension != "txt") && ($extension != "zip")) {
echo 'Unknown extension';
include ('static.php');
die();
}
$time = date("fYhis");
$new_file = $time.".".$extension;
$destination = "attachments/".$new_file;
$action = copy($_FILES['file']['tmp_name'],$destination);
if(!$action) {
echo 'File copy failed';
include ('static.php');
die();
} else {
echo $attacname." - File copy successful";
}
} else {
echo "The checkbox is not checked";
}
} else {
?>
<form action="index.php" method="post" enctype="multipart/form-data" name="form">
Upload attachment: <input class="incc" type="checkbox" name="option" value="1" />
<br />
Only .txt .zip files: <input type="file" name="file" />
<br />
Attachment Text:
<br />
<input type="text" name="attacname" /><br />
<input type="submit" value="submit" name="query" />
</form>
<?php } ?>

Sign In

Sponsor
Related

PHP Cookies and Sessions Tutorial

PHP Cookies and Sessions Tutorials

PHP Tutorials

Useful step-by-step PHP tutorials for beginners

Link Base 1.1. - Free PHP Link Index Script

Manage your links using a MySQL database. Features easy install, user submission, and an admin panel to add, edit and remove categories and links.

Adsense crawler errors and robots.txt

How to fix Google AdSense crawler errors in robots.txt

PHP Jquery Form

PHP Jquery Form allow your visitors to contact you directly from your website.

PHP highlight_string - PHP Tutorial

Outputs or returns a syntax highlighted version of the given PHP code using the colors defined in the built-in syntax highlighter for PHP. Requirement(s): PHP Server.

PHP Cookies - setcookie

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

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.

Site Recommendation

This script will allow your visitors to recommend your site to their friends.

Upload and Resize an Image with PHP

Tutorial - How to upload and resize image with PHP
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.