SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2011
    Location
    zziapex.com
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    file uploading problem

    When i try this code in Mozilla 10.0.1 then code works fine but when i run this code in IE 8.0 code is not working.
    what is the problem?anyone can tell me.


    <!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=utf-8" />
    <title>Untitled Document</title>
    </head>
    <body>

    <form action="uploading.php" enctype="multipart/form-data" method="post">
    Upload image<input type="file" name="file" id="file"/><br />
    <input type="submit" value="submit" name="submit"/>
    </form>
    <?php
    if($_POST['submit']){

    if($_FILES['file']['type']=="image/jpeg" || $_FILES['file']['type']=="image/gif" || $_FILES['file']['type']=="image/png"){
    if($_FILES['file']['error']>0)
    {
    echo "error";
    }
    else
    {
    echo $_FILES['file']['name']."<br/>";
    echo $_FILES['file']['type']."<br/>";
    echo ($_FILES['file']['size']/1024)."<br/>";
    echo $_FILES['file']['tmp_name'];
    $a = $_FILES['file']['name'];

    if (file_exists($_FILES['file']['name']))
    {
    echo $_FILES['file']['name']." alredy exists";
    }
    else
    {
    move_uploaded_file($_FILES['file']['tmp_name'],$_FILES['file']['name']);
    echo $_FILES['file']['name'];
    echo "<img src='$a'/>";
    }
    }
    }
    else
    {
    echo "file type wrong";
    }
    }
    ?>

    </body>
    </html>

  2. #2
    Foozle Reducer ServerStorm's Avatar
    Join Date
    Feb 2005
    Location
    Burlington, Canada
    Posts
    2,699
    Mentioned
    89 Post(s)
    Tagged
    6 Thread(s)
    @12345qwer

    In I.E. 8 what is the error you get? If you don't get an error then have you put echo/var_dump/print_r statements in your code to determine how far it gets? Have you checked the values in $_POST, and $_FILLES?

    Steve
    ictus==""

  3. #3
    Community Advisor silver trophy

    Join Date
    Nov 2006
    Location
    UK
    Posts
    2,547
    Mentioned
    40 Post(s)
    Tagged
    1 Thread(s)
    This code is insecure, it would be easy for an attacker to upload and execute a malicious file.

  4. #4
    SitePoint Enthusiast
    Join Date
    Jul 2011
    Location
    zziapex.com
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @EastCoast
    i know this code is insecure but i am in learning stage of php,

    @ServerStorm
    if statement is not working correctly, IE displaying else section of if condition only echo "file type wrong";


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
  •