SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP Upload Mime Types Upload Problem

    PHP Code:
    <?php



        
    include_once('config.php');



    ?>



    <!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>sparkload</title>

    <link href="iframe.css" rel="stylesheet" type="text/css" />

    </head>



    <body>

    <div id="right">

          <?php

              $error 
    'Incorrect file size or extension';

        if(
    $_FILES['userfile']['type'] == 'image/jpeg' or 'image/pjpeg' or 'image/gif' or 'video/avi' or 'video/msvideo' or 'image/bmp'or 'image/png' or 'image/x-png' or 'application/x-compressed'or 'application/x-shockwave-flash' or 'application/octet-stream' or 'application/zip' or 'audio/mpeg3' AND $_FILES['userfile']['size'] >= '26214400')
     {

                  
    $filename str_replace(' ''_'$_FILES['userfile']['name']);

                  
    $filename substr(sha1(rand(10000009999999)), 05) . '-'.$filename;

                  
    move_uploaded_file($_FILES['userfile']['tmp_name'], 'uploads/'.$filename);

                  
    $_SESSION['SL'] = $filename.';' $_SESSION['SL'];

              
    ?>

          Thank for using SparkLoad, below you can find the details of your upload.

          <p />

          <a href="main.php" target="_self"><b>Upload Again</b></a>

    </div>

    <div id="right-base">

            <div style="padding-bottom:3px;">Website:&nbsp;&nbsp; <input onclick="this.select()" name="link1" type="text" size="40" value=' <a href="<?php echo URI ?>"><img border="0" src="<?php echo URI 'uploads/' $filename ?>" alt="SparkLoad Image" /></a>'>

            </div>

          <div style="padding-bottom:3px;">Forums 1: <input onclick="this.select()" name="link2" type="text" size="40" value="[URL=<?php echo URI ?>][IMG]<?php echo URI 'uploads/' $filename ?>[/IMG][/URL]" />

          </div>

          <div style="padding-bottom:3px;">Forums 2: <input onclick="this.select()" name="link3" type="text" size="40" value="[url=<?php echo URI ?>][img=<?php echo URI 'uploads/' $filename ?>][/url]" />

          </div>

          <div style="padding-bottom:3px;">Direct Link: <input onclick="this.select()" name="link3" type="text" size="40" value="<?php echo URI 'uploads/' $filename ?>>

          </div>

    </div>


    <?php } else { echo '<div id="error">".$error."</div>'; } ?>
    I want it to make sure that all the other extensions that aren't described in IF should be displayed with an error but it's not working. It's still accepting the extensions and uploading them which is a great harm for my website.

    The website is HIDDEN and I would be glad if anyone could figure out the problem!

    Regards,
    Muhammad Haris
    Design to WordPress
    Free powerful and user-friendly control panel included.
    PM me for 10% refund discount on your first order.

  2. #2
    SitePoint Zealot
    Join Date
    May 2006
    Location
    Phoenix, AZ
    Posts
    162
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    make an array of your types, i odn't know if you can use a OR conjunctor for each of your MIME types..i think you have to do

    if($filemimetype=='this' OR $filemimetype=='that'),
    but it would be easier anyway to just make an array of your mime types, and do if(in_array());

    take a look, see if it works.
    PHP Code:
    $mimetypes = array(
    'image/jpeg',
    'image/pjpeg',
    'image/gif',
    'video/avi',
    'video/msvideo',
    'image/bmp',
    'image/png',
    'image/x-png',
    'application/x-compressed',
    'application/x-shockwave-flash',
    'application/octet-stream',
    'application/zip',
    'audio/mpeg3'
    )

    if(
    in_array($_FILES['userfile']['type'],$mimetypes) && $_FILES['userfile']['size'] >= '26214400'){
    ##Junk Here
    }
    ## You had a problem earlier with how you did quotes..make sure you are using correct single and double quotes.
    else { echo '<div id="error">'.$error.'</div>'; } 
    Kreative Development
    Infinite Possibilities

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by briancastellanos
    make an array of your types, i odn't know if you can use a OR conjunctor for each of your MIME types..i think you have to do

    if($filemimetype=='this' OR $filemimetype=='that'),
    but it would be easier anyway to just make an array of your mime types, and do if(in_array());

    take a look, see if it works.
    PHP Code:
    $mimetypes = array(
    'image/jpeg',
    'image/pjpeg',
    'image/gif',
    'video/avi',
    'video/msvideo',
    'image/bmp',
    'image/png',
    'image/x-png',
    'application/x-compressed',
    'application/x-shockwave-flash',
    'application/octet-stream',
    'application/zip',
    'audio/mpeg3'
    )

    if(
    in_array($_FILES['userfile']['type'],$mimetypes) && $_FILES['userfile']['size'] >= '26214400'){
    ##Junk Here
    }
    ## You had a problem earlier with how you did quotes..make sure you are using correct single and double quotes.
    else { echo '<div id="error">'.$error.'</div>'; } 
    Now it doesn't accepts any mime type
    Design to WordPress
    Free powerful and user-friendly control panel included.
    PM me for 10% refund discount on your first order.

  4. #4
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    replace '##Junk Here' with php/html code.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •