Home > Backend Development > PHP Tutorial > Image Fax Viewer Download Simple PHP Image Upload Program

Image Fax Viewer Download Simple PHP Image Upload Program

WBOY
Release: 2016-07-29 08:37:41
Original
1174 people have browsed it

The first one:
php part

Copy the code The code is as follows:


if($_FILES['file']['error'] > 0){
echo '!problem :';
switch($_FILES['file']['error'])
{
case 1: echo 'The file size exceeds the server limit';
case 2: echo 'The file size exceeds the server limit'; ';
               break; ';
              break; ';
                   break; ';
exit;
}
if($_FILES['file']['type']!='image/jpeg' && $_FILES['file']['type']!='image/gif') {
echo ‘The file is not a JPG or GIF image! ';
exit;
}
$today = date("YmdHis");
$filetype = $_FILES['file']['type'];
if($filetype == 'image/jpeg'){
$type = '.jpg';
}
if($filetype == 'image/gif'){
$type = '.gif';
}
$upfile = 'upfile/' . $today . $type;
if(is_uploaded_file($_FILES['file']['tmp_name']))
{
if(!move_uploaded_file($_FILES['file']['tmp_name'], $upfile))
{
echo 'Move File failed!
exit; br>';
echo 'File size :' . $_FILES['file']['size'] . 'bytes' . '
';
echo 'File path:' . $upfile;
echo '


' . '

';
$dirr = 'upfile/';
$dir = opendir($dirr);
echo $dirr . '--Listing:

    ';
    while ($file = readdir($dir)){
    echo "
  • $file
  • ";
    }
    echo '
';
closedir($dir);
?>


The second type:



Copy the code

The code is as follows:


if(empty($_GET[submit]))
{
?>


Send this file:


}else{
$path="uploadfiles/"; //Upload path
//echo $_FILES["filename"]["type"];
if (!file_exists($path))
{
//Check if the folder exists, if not, create it and give it the highest permissions
mkdir("$path", 0700);
}//END IF
//Allow Uploaded file format
$tp = array("image/gif","image/pjpeg","image/png");
//Check whether the uploaded file is of a type that is allowed to be uploaded
if(!in_array($_FILES[ "filename"]["type"],$tp))
{
echo "Incorrect format";
exit;
}//END IF
if($_FILES["filename"]["name"])
{
         $file1=$_FILES["filename"]["name"];                                                                                                                 $file1                                                                result=move_uploaded_file($_FILES["filename"]["tmp_name"],$file2);
//Specially note that the first parameter passed to move_uploaded_file here is the temporary file uploaded to the server
if($result)
{
       //echo "Uploaded successfully!".$file2;                echo "";
}//END IF
}
?>


The above introduces the simple PHP picture upload program for downloading the picture fax viewer, including the content of downloading the picture fax viewer. I hope it will be helpful to friends who are interested in PHP tutorials.


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template