HomeTuesday, May 23, 2017, 20:30:19
1

Upload Attachment - PHP Tutorial

Tuesday, February 10, 15, 10:33:26, 2 Yaers Ago Via wain, Hits: 2616
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

Site Recommendation

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

How to check checkbox checked

Checking if checkbox is checked with jQuery

Process Form Data with Jquery

jQuery, Process form data

Smarty Paginate Example - Smarty Pagination with PHP

Smarty Paginate Example, Smarty Pagination with PHP. SmartyPaginate: a class/plugin for data set pagination within the Smarty template environment

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.

How to insert new line (IP Address) with fwrite

How to insert new line (IP Address) with fwrite, Get IP address and write to file.

GuestBook PHP Script

Allow visitors to leave messages on your site. It features easy install, admin notification, and control panel to remove unwanted entries.

Upload Image with PHP [Example2]

[Example2] Tutorial - How to upload and resize image with PHP

Stack Overflow Clone Script - Ja2BU

Open source question and answer script written in PHP, MySQL and jQuery. Main features are: SEO friendly url's, private message system, rating system, comments system.

Email Link

HTML email link example
About Author

wain

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