SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jan 2005
    Location
    florida
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Upload .CSV issue

    Hey all,

    I am trying to upload a csv to my server. I have used the following script to upload Images, other text files and all without incedent. I am thinking that this is a size issue. For instance i get this result if I upload a gif () from print_r

    --------------------------------------------------
    Array
    (
    [file] => Array
    (
    [name] => about.gif
    [type] => image/gif
    [tmp_name] => D:\PHP\uploadtemp\php39.tmp
    [error] => 0
    [size] => 10235
    )

    )

    --------------------------------------------------

    Once I use a file larger than say 2 megs, I get this from print_r:

    --------------------------------------------------
    Array
    (
    [file] => Array
    (
    [name] => temp.csv
    [type] =>
    [tmp_name] =>
    [error] => 1
    [size] => 0
    )

    )
    --------------------------------------------------

    I made sure to turn the maxSize way up for testing purposes but that hasn't helped.Anyone got any ideas? Here's my Code:

    PHP Code:

    <?php 
    if (isset($_FILES['file'])) {

                                                        
    //echo "<pre>";
                                                        //print_r($_FILES);
                                                        //echo "</pre>";


        
    $KW_max_size=9000000000000;
        
    $extension="";
        if (
    is_uploaded_file($_FILES['file']['tmp_name'])) { 
            if(
    $_FILES['file']['size'] <= $KW_max_size) { 
                
    $realname $_FILES['file']['name']; 
                
    $ext_array =explode(".",$realname);
                
    $last_position count($ext_array) - 1
                
    $extension $ext_array[$last_position];
                
    $extAllowed=array ('all');
                
    $ii=count($extAllowed); 
                
    $flag=0;
                for(
    $i=0;$i<$ii;$i++){ 
                    if (
    $extAllowed[$i]==$extension)
                        
    $flag=1;
                }
                if (
    $extAllowed[0]=="all")
                    
    $flag=1;
                if(
    copy($_FILES['file']['tmp_name'], "DBBackUps/".$realname) && $flag==1) { 
                    
    Header("Location: login.php"); 
                     } else 
    Header("Location: size.php"); 
            } else 
    Header("Location: failed.php");
        } else     
    Header("Location: ext.php");   // Errors out here:
    }
    ?>

  2. #2
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this might be the issue with the maximum upload size allowed. try following
    PHP Code:
    phpinfo(); 
    and look for upload_max_filesize

    in my installation it is 2M and which is by default. so, if this is 2M then no matter what size you use it would not upload a file larger than that. (that's what i understood)
    there might be othe rways but i don't know about them


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
  •