Results 1 to 3 of 3
  1. #1

    Member Since
    Feb 28, 2010
    2.53 GHz Intel MacBook Pro 13.3" 4GB
    Mac CSV vs. Windows CSV
    I have a racing website that I'm building and I'm using a CSV template to load the result and points from the night. I have the template setup and save them as CSV's and load them. The problem is that if the CSV is created on a Windows machine it gives me an error that says the CSV file is not of the correct type. But if I take the exact same file and save a CSV on my Mac using MS Excel 2011 it works without a problem. I've even done it with Numbers and it worked.

    The function I'm using to check is crude (I've only been doing web work for a little over a year), but I'm getting hung up in the spot I have highlighted as red.

    If anyone could help me, I'd greatly appreciate it.


    <h1>Uploading file</h1>

    $userfile = $HTTP_POST_FILES['userfile'] ['tmp_name'];
    $userfileName = $HTTP_POST_FILES['userfile']['name'];
    $userfileSize = $HTTP_POST_FILES['userfile']['size'];
    $userfileType = $HTTP_POST_FILES['userfile']['type'];
    $userfileError = $HTTP_POST_FILES['userfile']['error'];
    $series= $HTTP_POST_VARS['series'];

    echo $series;

    if($userfileError > 0) {
    echo 'Problem: ';
    switch ($userfileError) {
    case 1: echo 'File exceeded upload_max_filesize'; break;
    case 2: echo 'File exceeded max_file_size'; break;
    case 3: echo 'File only partially uploaded'; break;
    case 4: echo 'No file uploaded'; break;

    //does file have right MIME type

    if ($userfileType != 'text/csv')
    echo 'Problem: file is not plain text';

    // put file in correct place

    $upfile = 'uploads/'.$userfileName;

    if (is_uploaded_file($userfile)) {
    if (!move_uploaded_file($userfile, $upfile))
    echo 'Problem: Could not move file to destination directory';
    echo 'Problem: Possible file upload attack. Filename:'.$userfileName;

    echo 'File uploaded successfully<br /><br />';

    // reformat the file contents
    $fp = fopen($upfile, 'r');
    $contents = fread ($fp, filesize ($upfile));
    fclose ($fp);

    $contents = strip_tags ($contents);
    $fp = fopen($upfile, 'w');
    fwrite($fp, $contents);

    echo 'Preview of uploaded file contents: <br /><hr />';
    if (($handle = fopen($upfile, 'r')) !== false) {
    while(($row = fgetcsv($handle, 100000, ",")) !== false){
    $query = join(",", $row)."<br/>";
    echo $query;
    echo '<br /><hr />';

    csv_file_to_mysql_table($upfile, $series);

  2. #2

    Dysfunction's Avatar
    Member Since
    Mar 17, 2008
    Tucson, AZ
    Way... way too many specs to list.
    Out of curiosity, try running dos2unix against it, then try importing it. Windows and *nix have completely different line formats in text files.
    This machine kills fascists
    Got # ? phear the command line!

  3. #3

    Member Since
    Feb 28, 2010
    2.53 GHz Intel MacBook Pro 13.3" 4GB
    I don't even have to run the dos2unix against the file. As soon as I move the file created in windows my MBP it uploads just fine.

    Unless you mean for me to run that on my Windows machine.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Export MAC contacts in CSV file format??
    By greendragonflyz in forum Switcher Hangout
    Replies: 1
    Last Post: 09-27-2012, 02:13 PM
  2. csv file changing format when opened from windows share
    By ochieman2000 in forum macOS - Apps and Games
    Replies: 1
    Last Post: 09-07-2012, 07:49 AM
  3. csv files
    By lasagna22 in forum Switcher Hangout
    Replies: 11
    Last Post: 07-22-2012, 11:20 AM
  4. .csv files help
    By n3qdz in forum Switcher Hangout
    Replies: 1
    Last Post: 02-22-2012, 02:25 AM
  5. Icalendar and CSV files
    By mgw1308 in forum macOS - Operating System
    Replies: 1
    Last Post: 12-19-2009, 11:12 AM

Posting Permissions

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