Skip to content

Notice: Undefined offset: 1 in C:\*********\Contact_Vcard_Parse.php on line 211 #21

@antonyf

Description

@antonyf

Hi.
I used this script, it works perfectly in the demo provided, but when i moved the files into my libraries folder, and then use it with a custom form input, i get the following error:

Notice: Undefined offset: 1 in C:******\libraries\Contact_Vcard_Parse.php on line 211

I'm using JQuery ajax to post the form and file like so:

var formData = new FormData();
formData.append('file', t[0].files[0]);
formData.append('func', 'convert');
formData.append('uid', uuid);
formData.append('token', token);
formData.append('_accesscode', '');
formData.append('_mailonly', '');
formData.append('_phoneonly', '');

$.ajax({
    url: 'http://locahost/website/index.php',
    type: 'POST',
   data : formData,
 // dataType:'json',
  contentType:false,
  cache:false,
  processData:false,
    success : function(data) {
        console.log(data);   
        return;
   },
    error: function(err){
        serverError();
        return;
    }
})

my php is the like so :

!empty($_POST['_mailonly']), 'phoneonly' => !empty($_POST['_phoneonly']), 'accesscode' => preg_replace('/[^1-9]/', '', $_POST['_accesscode']), )); $fileError = $_FILES['file']['error']; if ( $fileError != UPLOAD_ERR_OK ) { $out['res'] = encodeS( 1 ); echo json_encode( $out); return; } if ( $_FILES['file']['name'] != '' ) { $file_array = explode( ".", $_FILES['file']['name'] ); $extension = end( $file_array ); if ( strtolower($extension) == 'vcf' ) { if ( $conv->fromFile( $_FILES['file']['tmp_name'] ) ) { $temp_data = $conv->toCSV(); if(!temp_data){ $out['res'] = encodeS( 8 ); echo json_encode( $out ); return; } } else { $out['res'] = encodeS( 0 ); echo json_encode( $out ); return; } } else { $out['res'] = encodeS( 5 ); //not supported file echo json_encode( $out ); return; } } else { $out['res'] = encodeS( 4 ); //no file uploaded echo json_encode( $out ); return; } $out['res'] = encodeS( 6 ); // success $out['arr'] = $temp_data; echo json_encode( $out ); return; ?>

Any ideas??

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions