Ad block is installed and active. Please support us by disabling it.
HomeSaturday, October 21, 2017, 10:36:15
1

Upload Attachment - PHP Tutorial

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

These functions allow you to interact with and manipulate arrays in various ways. Arrays are essential for storing, managing, and operating on sets of variables.

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.

Preg_Match - PHP Form Validation

PHP form validation with preg_match

PHP DateTimeZone

PHP representation of time zone

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

PHP imagecreate

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

Preg_Match - PHP Email Validation

Validate email with preg_match in php

Creating a basic bad word filter in PHP

This tutorial will show you how to create a basic bad word filter in PHP

Imageline

Draws a line between the two given points.

Bookmark Current Page - PHP Tutorial

Bookmark current page with PHP example.
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.