Jump to content

GShadoW

New Members
  • Posts

    8
  • Joined

  • Last visited

GShadoW's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have also want to send you pm regarding this, but I was also unable to send pm...
  2. <?php //expected data: 45:16.5555;18:50.83722;1;19:30:35;17052015;1;0 //file_path to the saved file. $file_path = 'uploads/'; //file name of the temp file: $file_name = $_FILES['uploaded_file']['tmp_name']; //name of the saved file. $new_file = $_FILES['uploaded_file']['name']; // or set this variable to 'gps.txt' //if temp file doesn't exist. if(!file_exists($file_name)) { exit('The requested file was not uploaded.'); } //if the file exists, then get it's contents into a string. $contents = file_get_contents($file_name); //test for expected data. $contents = preg_replace('/[^0-9:.;]/','',$contents); //append it to the saved file, testing to make sure it saved. if(file_put_contents($file_path . $new_file,$contents . PHP_EOL, FILE_APPEND) !== FALSE) { echo 'success.'; } I send to server gps.text and with script above I only update existing gps.text on server with new line ( not overwriting existing file on server ) so expected line look like this: 45:16.5555;18:50.83722;1;19:30:35;17052015;1;0 I need help, what if I send same text, just last number increasing so it will look like this old 45:16.5555;18:50.83722;1;19:30:35;17052015;1;0 new 45:16.5555;18:50.83722;1;19:30:35;17052015;1;1 can I replace that same line with new until last number reaches 5, when reaches 5 then delete whole line example: current line on server is: 45:16.5555;18:50.83722;1;19:30:35;17052015;1;0 I send new line which is exactly same except last value ( 1 ) 45:16.5555;18:50.83722;1;19:30:35;17052015;1;1 <- update existing line 45:16.5555;18:50.83722;1;19:30:35;17052015;1;2 <- update existing line 45:16.5555;18:50.83722;1;19:30:35;17052015;1;3 <- update existing line 45:16.5555;18:50.83722;1;19:30:35;17052015;1;4 <- update existing line 45:16.5555;18:50.83722;1;19:30:35;17052015;1;5 <- delete line from file update until some line reach last value 5 and then delete it Anyone can help modify above script ?
  3. Thank you jcbones & Ch0cu3r now it works
  4. I send gps.txt from my mobile phone like this Sub Button1_Click Label1.Text="" Label2.Text="" Dim Path_Phone_Image As String Path_Phone_Image = File.DirRootExternal & "/" 'OR "/sdcard/ Dim name_image As String name_image="gps.txt" Up.doFileUpload( ProgressBar1,Label1,Path_Phone_Image & name_image,Url_Php_Page) End Sub my Url_Php_Page is located on my server www.xxxx.xxx/upload_file.php and php look's like this <?php $file_path = "uploads/"; $file_path = $file_path . basename( $_FILES['uploaded_file']['name']); if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $file_path)) { echo "success"; } else{ echo "fail"; } ?> it works to save gps.txt but it always overwrite it, not adding new line to existing text inside
  5. should I rename tmp_name to gps.txt ? I have try and it not working should I make some changes here ? $file_name = sys_get_tmp_dir() . $_SERVER['uploaded_file']['tmp_name'];
  6. i have placed your code in my php script but it's not working I have only renamed "filename.txt" to my gps.txt can you combine your code with my code in #1 post ?
  7. Hello @ll this is my first Q in forum Ok, I have a text file on my android device which I send to server every 2 min's text file contain's only 1 ( single line ) filename gps.txt that single line in text file look's like this 45:16.2432432;19:2465467;12;4 in a server directory I have filename gps.txt ( in that file I store data ) curently I use this php on my server ( named upload_file.php ) <?php $file_path = "uploads/"; $file_path = $file_path . basename( $_FILES['uploaded_file']['name']); if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $file_path)) { echo "success"; } else{ echo "fail"; } ?> but I only overwrite existing file!!! what I need is scrip that will add new line without overwriting anything in that file Can someone help me, I dont know nothing about php. B.R.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.