My script refuses to upload images with a .bmp extension...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pyromaster114
Forum Newbie
Posts: 19
Joined: Fri Mar 14, 2008 8:12 pm

My script refuses to upload images with a .bmp extension...

Post by pyromaster114 »

Okay basically I have a script that's supposed to upload images...
That's easy enough... but... it doesn't work for .bmp images... there's nothing in it that says it SHOULDN'T do it... it just tells it to upload the file... I don't get it...
What could be wrong with it?

Code: Select all

<?php
require_once('./config.php');
$session_timeout = "900";
if (($_SESSION['log_time'] + $session_timeout) < time()) { 
    $_SESSION = array(); //removes all session values
        if (isset($_COOKIE[session_name()])) { //checks for the cookie with the session name
            setcookie(session_name(), '', time()-42000); //removes said cookie
    }
        if (isset($_COOKIE['userid'])) { //checks for the cookie userid
            setcookie("userid",'',time()-3600*24*7); //removes said cookie
    }
    header('Location: ./index.php'); //if timed out move to login
    exit;
} else {
    $_SESSION['log_time'] = time();
}
if (!isset($_SESSION['logged-in']) || $_SESSION['logged-in'] !== true) {// is the one accessing this page logged in or not?
    
    exit;
}
    $userid = $_COOKIE['userid'];
    $r = mysql_fetch_array(mysql_query("SELECT * FROM users where id='$userid'"));//Select the user stuff
    $r2 = mysql_fetch_array(mysql_query("SELECT * FROM profile where id='$userid'"));//Select the user stuff from profile database
//checks if user is B&!!!
if ($r[ban] == "yes"){
header('Location: ../banned.php');
echo "you have been b&!!";
exit;
}
include('./navi.php');
 
$threadid = $_GET['threadid'];
 
//posts stuff if the user submitted a post...
if ($_POST['message'] != "") {
$userid= $_COOKIE['userid'];
    $r=mysql_fetch_array(mysql_query("select * from users where id='$userid'"));
    $threadid = $_GET['threadid'];
    $user = $r['username'];
    $message = $_POST['message'];
    $message2 = message_codes($message);
  $message3 = nl2br($message2);
    $imagename = $_FILES['new_image']['name'];
    $explodename = explode(".",$imagename);
    $countexplode = count($explodename);
    $n = $countexplode - '1';
    $ext = $explodename[$n];
  
    mysql_query("INSERT INTO `posts` (`ID`, `thread` , `user` , `content` , `ext` ) VALUES ('NULL', '$threadid', '$userid', '$message3', '$ext')") or die (mysql_error());
    
    if(1 == 1)
    {
    $lastid = mysql_insert_id();
    $imagename = $_FILES['new_image']['name'];
    $explodename = explode(".",$imagename);
    $countexplode = count($explodename);
    $n = $countexplode - '1';
    $ext = $explodename[$n];
    $source = $_FILES['new_image']['tmp_name'];
    $target = "./images/" . $lastid . "." . $ext;
    move_uploaded_file($source, $target);
    //sets up to check how many pages are in the thread
    $totalrows = mysql_num_rows(mysql_query("SELECT ID FROM posts WHERE thread = '$threadid'"));// Counts the total rows
    $limit = $threadpagelength;
    $totalpages = $totalrows / $limit;// Get the total pages
    $totalpages = ceil($totalpages);// Rounds the total pages to the highest possible number
    header("Location: ./threadview.php?threadid=$threadid&page=$totalpages");
    echo "$threadid";
    echo "$navi";
        echo "You created a post successfully.";
    }
    else 
    {
        echo "There has been an error. Please try again.";
    }
  }
 
 
$sendhere = <<<HERE
<form action="?threadid=$threadid" method="POST" enctype="multipart/form-data" id="something" class="uniForm" />
<table border="1" cellspacing="1" cellpadding="1">
<tr><td>Post:</td><td><textarea name="message" rows="5" cols="50" />
</textarea></td></tr>
<tr><td>File:</td><td><input name="new_image" id="new_image" type="file" size="30" /></td></tr>
<tr><td><input name="Submit" type="Submit" value="Send" /></td></tr>
</form>
<tr><td colspan=2>Formatting:<br />
<ul>
<li>italics = </li>
<li>bold = </li>
<li>smileys = :), :D, :P, :S, :(</li>
</ul>
</td></tr>
</table>
HERE;
$catid = $_GET['catid'];
echo $sendhere;
?>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Forums | Reply</title>
<link rel="stylesheet" type="text/css" href="./style.css" />
</head>
<body>
<br />
</body>
</html>
pyromaster114
Forum Newbie
Posts: 19
Joined: Fri Mar 14, 2008 8:12 pm

Re: My script refuses to upload images with a .bmp extension...

Post by pyromaster114 »

Okay I figured out there's apparently an error due to the size of the image...
How do I make it so you can upload files that are of a larger size?
I don't see anything in the script that's limiting it... but then again... I might be overlooking something..
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: My script refuses to upload images with a .bmp extension...

Post by John Cartwright »

pyromaster114 wrote:Okay I figured out there's apparently an error due to the size of the image...
How do I make it so you can upload files that are of a larger size?
I don't see anything in the script that's limiting it... but then again... I might be overlooking something..
In .htaccess

Code: Select all

php_value upload_max_filesize 50M
php_value post_max_size 50M
these values can also be changed in your php.ini, or using ini_set()
pyromaster114
Forum Newbie
Posts: 19
Joined: Fri Mar 14, 2008 8:12 pm

Re: My script refuses to upload images with a .bmp extension...

Post by pyromaster114 »

THANK YOU... I never would have figured that out lol... I would have sat there staring at the script for the next 20 days...
It works now... ^_^
Post Reply