Hey Guys,
I am (trying) to create a script to upload ppc reports from the associated search engines. I have no problem in uploading the file but processing it in turning out to be a bit of a nightmare.
My code for the upload form is:
<form method="post" autocomplete="off" enctype="multipart/form-data">
<label for="month">Month</label> / <label for="year">Year</label>
<select name="month" id="month">
<option value="01">Jan</option>
<option value="02">Feb</option>
... Edited to save length ...
<option value="11">Nov</option>
<option value="12">Dec</option>
</select>
<select name="year" id="year">
<option value="2007">2007</option>
</select>
<label for="se">Search Engine</label>
<select name="se" id="se">
<option value="">-- Please Select --</option>
<option value="google"<?php if ($post['se'] == 'google') {?> selected="selected"<?php } ?>>Google</option>
<option value="miva"<?php if ($post['se'] == 'miva') {?> selected="selected"<?php } ?>>Miva</option>
<option value="msn"<?php if ($post['se'] == 'msn') {?> selected="selected"<?php } ?>>MSN</option>
<option value="overture"<?php if ($post['se'] == 'overture') {?> selected="selected"<?php } ?>>Overture</option>
</select>
<label for="uploadfile">Upload File</label>
<input type="file" name="uploadfile" />
<br />
<input type="submit" value="Upload" />
</form>
To process the file, I have used file().
$file = file($_FILES['uploadfile']['tmp_name']);
When I print this text, this is what happens:
Array
(
[0] => ÿþM a r k e t ,
[1] =>
[2] => T i t l e , A c c o u n t A c t i v i t y D e t a i l
[3] => I n p u t s
[4] => B e g i n D a t e , 0 6 / 0 1 / 2 0 0 7
[5] => E n d D a t e , 0 6 / 2 7 / 2 0 0 7
[6] => A c c o u n t I D , 8 3 3 0 8 4 4 5 5 0
[7] => R e p o r t L e v e l , A g g r e g a t e
[8] => P r o d u c t T y p e , A l l
[9] =>
[10] =>
[11] => N a m e , A g g r e g a t e
[12] =>
[13] =>
[14] => S t a r t D a t e , E n d D a t e , K e y w o r d , I m p r e s s i o n s , T o t a l C l i c k s , T o t a l C o s t £ , U R L , C o n v e r s i o n s , C o n v e r s i o n R a t e , C o s t / C o n v e r s i o n £
... Edited to save space ...
[52] => , , , 6 0 3 4 5 1 , 3 9 5 4 , 9 0 0 7 . 4 6 , , 0 , , , S u m
[53] => , , , , , , , , 0 , , T o t a l A v g .
[54] =>
)
Notice the extra spacing between each character and the weird characters at the beginning?
The weird thing is than when I use file_get_contents() everything looks ok but then when I use explode("\n") I get the same results.
I am using PHP version 5.1.6 on a linux machine. Does anyone have any ideas?
I have attached the report from Overture that is used to upload and process.