Current location: Hot Scripts Forums » Programming Languages » PHP » File type is not allowed..


File type is not allowed..

Reply
  #1 (permalink)  
Old 10-19-04, 04:52 AM
steveo steveo is offline
Wannabe Coder
 
Join Date: Jun 2004
Posts: 130
Thanks: 0
Thanked 0 Times in 0 Posts
File type is not allowed..

Hello, I'm having a bit of trouble trying to let only tw file types allowed to be uploaded.

If you could look at my code and try find out whats wrong. Id be greatfull.

PHP Code:

        <?php

// Image upload bit START
    
    
if ($_FILES['image']['name'] == "") {
    
#there's no file name return an error
    
echo "Please select a file to upload!\n";
    exit;    }

    
$uploads "screenshots/temp/";
    
$types_array = array('image/jpeg','image/jpg');

    if (!
in_array($_FILES['image']['type'],$types_array)) 
            {
    echo 
"File type not allowed!";
    }
    exit;
 {
    
// MySQL Connection Variables here.

$hostname "--"// default value but change this value as required.
$user "----"// change this to your username
$pass "1-----tg"// change this to your MySQL db password
$dbname "---"// Change this to your database name

$connection mysql_connect("$hostname"$user"$pass");
$db mysql_select_db($dbname $connection) or die ("Cannot select db");
$date2 date("jS M, Y h:iA");
    
$result=MYSQL_QUERY("INSERT INTO screenshots (filename, name, description, date)".
        
"VALUES ('$image','$member','$text','$date2')") or die ("Data not inserted into database");

    
$idmysql_insert_id();
    print 
"Your screenshot has been added. Click <a href='http://tibiagallery.co.uk/members/?acc=screenshots'>here</a> to see it.";

     
$result1=MYSQL_QUERY("UPDATE screenshots SET filename = $id WHERE id = $id");
     
$pointscheck mysql_query("SELECT * FROM membership WHERE name = '$member'");
$points mysql_fetch_array($pointscheck);
$point $points['points'] + 1;
$addpoint mysql_query("UPDATE membership SET points = '$point' WHERE name = '$member'");

    
MYSQL_CLOSE();

move_uploaded_file($_FILES['image']['tmp_name'], "".$uploads."/".$_FILES['image']['name']) or die ("Couldn't upload file!");

//******************************************************************************
        
$img $_FILES['image']['name'];

        
$img_name 'screenshots/temp/'.$img;

        
$new_name1 'screenshots/normal/'.$id.'.jpg';

// Move file from temp to norm
        
rename ("$img_name""$new_name1")  or die ("Could not move file");


//******************************************************************************
}
 
?>
When I try to upload any file, it returns that file type is not allowed.

Last edited by steveo; 10-19-04 at 04:54 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
I most definately suggest DevelopingCentral.com For Any Website Design/Development! Salty777 General Advertisements 2 10-01-04 05:27 AM
type of file validation rush989 JavaScript 0 08-31-04 02:54 PM
Select one type of file only from directory Bonzo PHP 6 04-27-04 05:58 AM
Getting the created file (fopen/fwrite) Programme PHP 5 02-14-04 04:09 PM
Upload file type and size limiter! Arctic ASP 1 08-02-03 08:06 PM


All times are GMT -5. The time now is 10:12 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.