<?php
ob_start();
session_start(); /// initialize session
include("./inc/pw.php");
check_logged();
include("./inc/dirscan.php");
include("./inc/array_xml.php");
include("./inc/jscript.php");
/*
This is the PHP code for the Uploading PHP Files Using PHP Tutorial
You may use this code in your own projects as long as this
copyright is left in place. All code is provided AS-IS.
This code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
For the rest of the code visit http://www.WebCheatSheet.com
Copyright 2007 WebCheatSheet.com
*/
echo "<table width='700' border='0' cellspacing='0' cellpadding='2'>" ;
echo "<tr>";
echo "<td><h1>";
//Check that we have a file
if((!empty($_FILES["uploaded_file"])) && ($_FILES['uploaded_file']['error'] == 0)) {
// echo($_POST['imagefolder']);
//Check if the file is JPEG image and it's size is less than 350Kb
$filename = basename($_FILES['uploaded_file']['name']);
$ext = substr($filename, strrpos($filename, '.') + 1);
// if (($ext == "jpg") && ($_FILES["uploaded_file"]["type"] == "image/jpeg") &&
if (($ext == "jpg") || ($ext == "png") || ($ext == "gif") || ($ext == "swf") || ($ext == "mp3") || ($ext == "flv") || ($ext == "JPG") || ($ext == "mp4") &&
($_FILES["uploaded_file"]["size"] < 40350000)) {
//Determine the path to which we want to save this file
// $newname = dirname(__FILE__).'/upload/'.$filename;
$newname = "".$_POST['imagefolder']."/".$filename;
//Check if the file with the same name is already exists on the server
if (!file_exists($newname)) {
//Attempt to move the uploaded file to it's new place
if ((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$newname))) {
echo "It's done! The file has been saved as: ".$newname;
} else {
echo "Error: A problem occurred during file upload!";
}
} else {
if ($filename!="contact_image.jpg"){
$pieces=explode('.',$filename);
if ((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$_POST['imagefolder']."/".$pieces[0]."_1.".$pieces[1]))) {
echo "File already exist! The file has been saved as: ".$_POST['imagefolder']."/".$pieces[0]."_1.".$pieces[1];
// echo "Error: File ".$_FILES["uploaded_file"]["name"]." already exists";
} else {
echo "Error: A problem occurred during file upload!";
}
}else{
unlink($newname);
if ((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$newname))) {
echo "It's done! Contact image has been saved as: ".$newname;
}
}}
} else {
echo "Error: Only files under 42350Kb are accepted for upload";
}
} else {
echo "Error: No file uploaded";
}
echo "</h1></td>";
//decido pagina di ritorno
if ($_POST['page']!='editcat'){
echo "<tr><td align='center'><a href='upnews.php'>BACK TO UPLOAD PAGE</a></td></tr>";
}else{
echo "<tr><td align='center'><a href='editcat.php'>BACK TO GALLERY CATEGORY PAGE</a></td></tr>";
}
echo "</tr>";
echo "</table> " ;
?>