Hello,
first post , and asking for help im afraid. Very new to PHP, was making good progress I thought , but im stuck with this part. I have a uploading form that works perfectly and uploads everything to "uploads/images" . What Im trying to do is upload .txt or .rtf files to "uploads/text" and .jpg and .gif's to "uploads/images . I thought this wasnt going to be too difficult but im totally stuck and have spent hours trying to solve this. If anyone could help at all and show my what I'm doing wrong, Id be very very grateful!
This is the code as it stands. Right now, it ALWAYS goes to "uploadfail.php" and the file does not upload. If I remove all the code relating to filetype then both the text and image files succesully upload and I go to "uploadsucess.php"
Code: <?
require('connection.php');
//my_sql_real..... makes it safe against mysql injection
$title = mysql_real_escape_string($_POST['title']);
$date = mysql_real_escape_string($_POST['date']);
$author = mysql_real_escape_string($_POST['author']);
$description = mysql_real_escape_string($_POST['description']);
$type = mysql_real_escape_string($_POST['type']);
$imgName = $_FILES['pic']['name'];
$imgTmp = $_FILES['pic']['tmp_name'];
$imgSize = $_FILES['pic']['size'];
$imgType = $_FILES['pic']['type'];
$maxFileSize = 200000;
if ($imgType == "image/jpeg" || $imgType == "image/gif" || $imgType == "application/rtf" || $imgType == "application/x-rtf" || $imgType == "text/richtext" || $imgType == "text/plain" ) {
$error = "";
} else {
$error = "type";
}
if ($imgType == "image/jpeg" || $imgType == "image/gif" ) {
$filetype = "image";
}
if ($imgType == "application/rtf" || $imgType == "application/x-rtf" || $imgType == "text/richtext" || $imgType == "text/plain" ) {
$filetype = "text";
} else {
$filetype = "other";
}
if ($imgSize > $maxFileSize) {
$error = "size";
}
if ($error == "" && $imgName != "" && $filetype == "image" ) {
$filePath = "uploads/images/".$imgName;
move_uploaded_file($imgTmp, $filePath);
if ($error == "" && $imgName != "" && $filetype == "text" ) {
$filePath = "uploads/text/".$imgName;
move_uploaded_file($imgTmp, $filePath);
//another securtiy measure sprintf
$query = sprintf("INSERT INTO gallery(title,date,author,type,description,path) VALUES ('%s' , '%s' ,'%s' ,'%s' ,'%s' ,'%s' )", $title,$date,$author,$type,$description,$filePath);
if (!mysql_query($query, $connect)) {
die();
} else {
header("Location: uploadsuccess.php");
}
}
} else {
header("Location: uploadfail.php");
}
?>
Data storage spaces in varchar2
Trying to understand what's happening.
add to sql result
ok see rite now my sites hit counter is counted from the mysql visitor log i need to clear it after atleast 20 000 but i dont wana loose the count this is how i get the count now how do i add 20
CE 7.1 and External GIS integration
Hi All,
Help building / using array
First - this is a cross-posting, if this is wrong I apologise! What started out as a MySQL query question (original post http://www.phpfreaks.com/forums/index.php/topic,273323.0.html) has become a PHP
How to insert random unique values in 2 columns ?
I have table with 2 columns
How would I convert this into code using an if statement?
ES equals exam score m equals $mean s equals $total. I already coded my mean and total so I'm not going to post my code unless it is necessary. I want to know how to get this into code form using if
Performance impact of cookies
Hi, I was just wondering what impact there would be in terms of performance if you where to set then increment the value of a cookie on each page of a site. Also, being a server side script; how
Taxonomy? Classification? Categorisation?
Not sure if there is a way around this classification problem
Multiple Options for a Single Page
For this example I want to use the Handlers option which is under Fed Admin and all the related coding to the handlers option is found on the handlers.php page which includes a list of handlers with a
Interpret Order
Hello all,I'm wondering if I have this:Code: $switch = array( 'one' => $this->RenderOne() ,'two' => $this->RenderTwo());Would php call the function