Bekijk de onderstaande video om te zien hoe je onze site als een web app op je startscherm installeert.
Opmerking: Deze functie is mogelijk niet beschikbaar in sommige browsers.
(upload.php)
<html>
<head>
<title>Multiple image upload</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
<?
// File Maximum size
$max_size = 400000;
$to =$_POST['email'];
$from = "admin@localhost";
$subject ="Images with the Changed Resolution";
$message = "My message";
$headers = "From: ($from)";
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// headers for attachment
$headers .= "\nMIME-Version: 1.0\n"."Content-Type: multipart/mixed;\n"." boundary=\"{$mime_boundary}\"";
// multipart boundary
$message = "This is a multi-part message in MIME format.\n\n"."--{$mime_boundary}\n"."Content-Type: text/plain; charset=\"iso-8859-1\"\n"."Content-Transfer-Encoding:7bit\n\n".$message."\n\n";
$message = "--{$mime_boundary}\n";
// Checking whether any field is empty
foreach($_FILES['images']['name'] as $image){
if($image==""){
echo "Some fields are not filled!<br><a href='javascript:history.go(-1);'>Back</a>"; exit;
}
}
while(list($key,$value) = each($_FILES['images']['name'])){
if($_FILES['images']['size'][$key]>$max_size){ echo "The file is too big<br><a href='javascript:history.go(-1);'>Back</a>"; exit; }
// Fetching files extensions
$ext = substr($value, strrpos($value, '.') + 1);
$ext=strtolower($ext);
if($ext=="bmp"||$ext=="jpg"||$ext=="png"||$ext=="jpeg"){
if(!empty($value)){
$filename = $value;
$filename=str_replace(" ","_",$filename);
$pos = strripos($filename, '.');
$filename=substr($filename, 0, $pos);
$add= "upimages/".$filename."_".rand().".".$ext;
// Add _ inplace of blank space in file name, you can remove this line
// echo $_FILES['images']['type'][$key];
// echo "<br>";
copy($_FILES['images']['tmp_name'][$key], $add);
chmod("upimages",0777);
$image=new Imagick($add);
$image->setImageResolution(600,600);
$image->writeImage($add);
$array=$image->getImageResolution();
$file = fopen($add,"rb");
$data = fread($file,filesize($add));
fclose($file);
$data = chunk_split(base64_encode($data));
$message.="Content-Type:{\"application/octet-stream\"};\n"."name=\"$add\"\n".
"Content-Disposition:attachment;\n"." filename=\"$add\"\n".
"Content-Transfer-Encoding: base64\n\n".$data."\n\n";
$message.="--{$mime_boundary}\n";
}
} else {
echo "Image file type is wrong.Select(JPG,BMP,PNG)<br> <a href='javascript:history.go(-1);'>Back</a>"; exit;
}
}
$message .= "--{$mime_boundary}--\n";
$ok = @mail($to, $subject,$message, $headers);
if ($ok) {
echo "<p>mail sent to $to!</p><a href='index.php'>More</a>";
} else {
echo "<p>mail could not be sent!</p>";
}
?>
</body>
</html>
=============================================
script2: (index.php)
<?php
$max_no_img=2; // Maximum number of images value to be set here
?>
<html>
<head>
<title>Input Images</title>
<script type="text/javascript">
function validate(){
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
var str= document.frm.email.value;
if(document.frm.uname.value==""){
alert("Please enter your name!");
document.frm.uname.focus();
return false;
}
if(document.frm.email.value==""){
alert("Please enter email address!");
document.frm.email.focus();
return false;
}
if(!filter.test(str)){
alert("Please insert valid email address!");
document.frm.email.focus();
return false;
}
return true;
}
</script>
</head>
<body bgcolor="#ffffcc">
<center>
<form name="frm" method='post' action='upload.php' enctype='multipart/form-data'>
<table border="0" cellpadding="0" cellspacing="0" width="55%">
<tr>
<td width="37%" bgcolor="#FCFAD8">
<h2 align="center">
<font color="#000080">User Form</font></h2>
</td>
</tr>
<tr>
<td width="37%" align="right" bordercolor="#DFDFFF" bgcolor="#DFDFFF">
<p align="left"><font color="#800000"><b>Your Name </b></font><input type="text" name="uname"></p>
</td>
</tr>
<tr>
<td width="37%" align="right" bordercolor="#DFDFFF" bgcolor="#DFDFFF">
<p align="left"><font color="#800000"><b>Your Email </b></font><input type="text" name="email"></p>
</td>
</tr>
<tr>
<td width="37%" bordercolor="#DFDFFF" bgcolor="#DFDFFF">
<table border="0" cellpadding="0" cellspacing="0" width="480">
<td width="137">
<? for($i=1;$i<=$max_no_img;$i++){ ?>
<tr>
<td width="137"><font color="#800000"><b>Attachment <?=$i?>:</b></font></td>
<td width="339"><input type="file" name='images[<?=$i?>]' class='bginput'></td>
</tr>
<td width="137">
<?}?>
</table>
</td>
</tr>
<tr>
<td width="37%" bordercolor="#DFDFFF" bgcolor="#DFDFFF">
<p align="center"> </td>
</tr>
<tr>
<td width="37%" bgcolor="#DFDFFF" bordercolor="#DFDFFF">
<p align="center"><input type="submit" value="Submit" onClick="return validate();"></td>
</tr>
</table>
</form>
</center>
</body>
</html>
(index.php)
<?php
$max_no_img=2; // Maximum number of images value to be set here
?>
<html>
<head>
<title>Input Images</title>
<script type="text/javascript">
function validate(){
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
var str= document.frm.email.value;
if(document.frm.uname.value==""){
alert("Please enter your name!");
document.frm.uname.focus();
return false;
}
if(document.frm.email.value==""){
alert("Please enter email address!");
document.frm.email.focus();
return false;
}
if(!filter.test(str)){
alert("Please insert valid email address!");
document.frm.email.focus();
return false;
}
return true;
}
</script>
</head>
<body bgcolor="#ffffcc">
<center>
<form name="frm" method='post' action='upload.php' enctype='multipart/form-data'>
<table border="0" cellpadding="0" cellspacing="0" width="55%">
<tr>
<td width="37%" bgcolor="#FCFAD8">
<h2 align="center">
<font color="#000080">User Form</font></h2>
</td>
</tr>
<tr>
<td width="37%" align="right" bordercolor="#DFDFFF" bgcolor="#DFDFFF">
<p align="left"><font color="#800000"><b>Your Name </b></font><input type="text" name="uname"></p>
</td>
</tr>
<tr>
<td width="37%" align="right" bordercolor="#DFDFFF" bgcolor="#DFDFFF">
<p align="left"><font color="#800000"><b>Your Email </b></font><input type="text" name="email"></p>
</td>
</tr>
<tr>
<td width="37%" bordercolor="#DFDFFF" bgcolor="#DFDFFF">
<table border="0" cellpadding="0" cellspacing="0" width="480">
<td width="137">
<? for($i=1;$i<=$max_no_img;$i++){ ?>
<tr>
<td width="137"><font color="#800000"><b>Attachment <?=$i?>:</b></font></td>
<td width="339"><input type="file" name='images[<?=$i?>]' class='bginput'></td>
</tr>
<td width="137">
<?}?>
</table>
</td>
</tr>
<tr>
<td width="37%" bordercolor="#DFDFFF" bgcolor="#DFDFFF">
<p align="center"> </td>
</tr>
<tr>
<td width="37%" bgcolor="#DFDFFF" bordercolor="#DFDFFF">
<p align="center"><input type="submit" value="Submit" onClick="return validate();"></td>
</tr>
</table>
</form>
</center>
</body>
</html>
=====
(upload.php:)
<html>
<head>
<title>Multiple image upload</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
<?
// File Maximum size
$max_size = 400000;
$to =$_POST['email'];
$from = "yadmin@localhost";
$subject ="Images with the Changed Resolution";
$message = "My message";
$headers = "From: ($from)";
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// headers for attachment
$headers .= "\nMIME-Version: 1.0\n"."Content-Type: multipart/mixed;\n"." boundary=\"{$mime_boundary}\"";
// multipart boundary
$message = "This is a multi-part message in MIME format.\n\n"."--{$mime_boundary}\n"."Content-Type: text/plain; charset=\"iso-8859-1\"\n"."Content-Transfer-Encoding:7bit\n\n".$message."\n\n";
$message = "--{$mime_boundary}\n";
// Checking whether any field is empty
foreach($_FILES['images']['name'] as $image){
if($image==""){
echo "Some fields are not filled!<br><a href='javascript:history.go(-1);'>Back</a>"; exit;
}
}
while(list($key,$value) = each($_FILES['images']['name'])){
if($_FILES['images']['size'][$key]>$max_size){ echo "The file is too big<br><a href='javascript:history.go(-1);'>Back</a>"; exit; }
// Fetching files extensions
$ext = substr($value, strrpos($value, '.') + 1);
$ext=strtolower($ext);
if($ext=="bmp"||$ext=="jpg"||$ext=="png"||$ext=="jpeg"){
if(!empty($value)){
$filename = $value;
$filename=str_replace(" ","_",$filename);
$pos = strripos($filename, '.');
$filename=substr($filename, 0, $pos);
$add= "upimages/".$filename."_".rand().".".$ext;
// Add _ inplace of blank space in file name, you can remove this line
// echo $_FILES['images']['type'][$key];
// echo "<br>";
copy($_FILES['images']['tmp_name'][$key], $add);
chmod("upimages",0777);
$image=new Imagick($add);
$image->setImageResolution(600,600);
$image->writeImage($add);
$array=$image->getImageResolution();
$file = fopen($add,"rb");
$data = fread($file,filesize($add));
fclose($file);
$data = chunk_split(base64_encode($data));
$message.="Content-Type:{\"application/octet-stream\"};\n"."name=\"$add\"\n".
"Content-Disposition:attachment;\n"." filename=\"$add\"\n".
"Content-Transfer-Encoding: base64\n\n".$data."\n\n";
$message.="--{$mime_boundary}\n";
}
} else {
echo "Image file type is wrong.Select(JPG,BMP,PNG)<br> <a href='javascript:history.go(-1);'>Back</a>"; exit;
}
}
$message .= "--{$mime_boundary}--\n";
$ok = @mail($to, $subject,$message, $headers);
if ($ok) {
echo "<p>mail sent to $to!</p><a href='index.php'>More</a>";
} else {
echo "<p>mail could not be sent!</p>";
}
?>
</body>
</html>
We gebruiken essentiële cookies om deze site te laten werken, en optionele cookies om de ervaring te verbeteren.