Uploading .CSV

Discussion in 'PHP' started by gigamike, Nov 3, 2006.

  1. #1
    Hi guys,

    i hope you can help me. Im having trouble uploading a .CSV file that is 25MB in file size. I already set the ff. fo php.ini

    max_execution_time = 3600
    max_input_time = 3600
    memory_limit = 100M
    upload_max_filesize = 200M
    post_max_size = 400M

    i can get the value of the $_FILES['form_data']['name'] but i cant echo $_FILES['form_data']['tmp_name']

    Note: my form also has a enctype="multipart/form-data" name="form1"

    Do you think guys there is an issue with .CSV files or i miss something

    Thanks,

    mike
     
    gigamike, Nov 3, 2006 IP
  2. datropics

    datropics Peon

    Messages:
    309
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Find out from your host - some hosts even though you have your ini edited don't allow that.

    Unless ofcourse you are on your own production machine
     
    datropics, Nov 3, 2006 IP
  3. gigamike

    gigamike Active Member

    Messages:
    165
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    thanks for the help datropics. Well already solved it and the error is in the form, its really kind of akward but i just fix the proper html tag.

    tnx again,

    mike
     
    gigamike, Nov 3, 2006 IP
  4. gigamike

    gigamike Active Member

    Messages:
    165
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #4
    Guys,

    please help me :(, im having trouble with my .CSV file. My goal is to be able to display it per row. Now if the parser reach column G, the display is destroy, what i mean is that the next row display an error.

    Here's the sample .CSV file http://www.michaelgalon.com/test/

    here is my code:

    $file_data=addslashes(fread(fopen($file, "r"), filesize($file)));
    $oneField = strtok($file_data, ",");
    $i=0;
    while($oneField){
    $i++;
    $name1=$oneField;
    $oneField=strtok(",");
    $address1=$oneField;
    $oneField=strtok(",");
    $zip=$oneField;
    $oneField=strtok(",");
    $city=$oneField;
    $oneField=strtok(",");
    $company_reg_id=$oneField;
    $oneField=strtok(",");
    $court_location=$oneField;
    $oneField=strtok(",");
    $fg_data=$oneField;
    $oneField=strtok("\n");
    $payment_date=$oneField;
    }

    Thanks a lot guys...mike
     
    gigamike, Nov 7, 2006 IP
  5. gigamike

    gigamike Active Member

    Messages:
    165
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #5
    ok guys, i already figure out why, coz column G contains a comma that is why when i parse my .CSV occurs error when displaying the record per row. Any alternative so i can read and display this file row by row

    http://www.michaelgalon.com/test

    Thanks again,

    mike



     
    gigamike, Nov 7, 2006 IP
  6. gigapromoters

    gigapromoters Peon

    Messages:
    309
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    gigapromoters, Nov 7, 2006 IP
  7. gigamike

    gigamike Active Member

    Messages:
    165
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #7
    hi, thanks, but what i did was a adjust some php directives (php.ini) so that my page will not timeout...

    Maybe you have an idea on how i can ignore the comma in ColumnG so i can move to Column H :( though in reality .CSV is comma delimeted...

    thanks again,

    mike


     
    gigamike, Nov 7, 2006 IP
  8. gigamike

    gigamike Active Member

    Messages:
    165
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #8
    Hi Guys,

    i already figured it out, when .xls is converted to .csv, all column is delimited comma, in addition (this is what i missed) all column wit a comma will be automatically enclosed by a double qoute, example below


    .xls
    Column A Column B
    1 mike php
    2 mik php, foxpro
    3 me visual basic

    when converted to .csv

    mike, php, mik, "php, foxpro", me, visual basic

    second there is already a function that reads this kind of file, so insted of using explode() using comma, use fgetcsv. Just check the php.net for this...

    Thanks again,

    mike
     
    gigamike, Nov 7, 2006 IP