File: WIAdmin/WICore/WIClass/ajax_php_file.php

Recommend this page to a friend!
  Classes of Jules Warner  >  WICMS  >  WIAdmin/WICore/WIClass/ajax_php_file.php  >  Download  
File: WIAdmin/WICore/WIClass/ajax_php_file.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: WICMS
Database driven content management system with PDO
Author: By
Last change:
Date: 3 years ago
Size: 1,391 bytes
 

Contents

Class file image Download
<?php
if(isset($_FILES["file"]["type"]))
{
$validextensions = array("jpeg", "jpg", "png");
$temporary = explode(".", $_FILES["file"]["name"]);
$file_extension = end($temporary);
if (((
$_FILES["file"]["type"] == "image/png") || ($_FILES["file"]["type"] == "image/jpg") || ($_FILES["file"]["type"] == "image/jpeg")
) && (
$_FILES["file"]["size"] < 100000)//Approx. 100kb files can be uploaded.
&& in_array($file_extension, $validextensions)) {
if (
$_FILES["file"]["error"] > 0)
{
echo
"Return Code: " . $_FILES["file"]["error"] . "<br/><br/>";
}
else
{
if (
file_exists("WIMedia/Img/header/" . $_FILES["file"]["name"])) {
echo
$_FILES["file"]["name"] . " <span id='invalid'><b>already exists.</b></span> ";
}
else
{

$sourcePath = $_FILES['file']['tmp_name']; // Storing source path of the file in a variable
$targetPath = "WIMedia/Img/header/".$_FILES['file']['name']; // Target path where file is to be stored
move_uploaded_file($sourcePath,$targetPath) ; // Moving Uploaded file
echo "<span id='success'>Image Uploaded Successfully...!!</span><br/>";
echo
"<br/><b>File Name:</b> " . $_FILES["file"]["name"] . "<br>";
echo
"<b>Type:</b> " . $_FILES["file"]["type"] . "<br>";
echo
"<b>Size:</b> " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
echo
"<b>Temp file:</b> " . $_FILES['file']["tmp_name"] . "<br>";
}
}
}
else
{
echo
"<span id='invalid'>***Invalid file Size or Type***<span>";
}

}


For more information send a message to info at phpclasses dot org.