Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8308149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:42:49+00:00 2026-06-08T18:42:49+00:00

i need to get the string from on php file someone know how can

  • 0

i need to get the string from on php file someone know how can i do this?

My.php that write and read contenute of one file

<?php
 $dir = '/var/www/devData/test';

 // create new directory with 777 permissions if it does not exist yet
 // owner will be the user/group the PHP script is run under
 if ( !file_exists($dir) ) {
  mkdir ($dir, 0777);
 }
 if (isset($_POST['data'])) {

         $stringData = $_POST['data'];
         $file = "/var/www/devData/test/ciao.txt"; 
         $fh = fopen($file, 'r+') or die("can't open file");
         fwrite($fh, $stringData);
         $theData = fread($fh, filesize($myFile)); //this is the string that i have to pass
         fclose($fh); 

         return $theData;

 }


 ?>

my.js scrpt that use the methode get for retrive the strng from my php file

 function addLabelCustom_options() {
  var select = document.getElementById('label_custom');

 $.get("JS/foo.php", function(result){ alert(result) }, "json");


 /* $.ajax({
  url:'/var/www/devData/test/ciao.txt',
  success: function (data){
  //parse ur data
  //you can split into lines using data.split('\n') 
  //use regex functions to effectivley parse
  var label_parsed = data.splitCSV();
    select.options[0] = new Option("-- Select Label --",0);
    var label_sort = new Array();

    for (var i=0; i<label_parsed.length-1; i++)
        label_sort.push(label_parsed[i][1]);

    label_sort.sort();
    for (var j=0; j<label_sort.length-1; j++)
        select.options[j+1] = new Option(label_sort[j],j+1);

}
});

*/
}

i Just need to get the contenute of the string $theData
Looks like if i don’t retrive any string….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:42:51+00:00Added an answer on June 8, 2026 at 6:42 pm
    <?php
     $dir = '/var/www/devData/test';
    
     // create new directory with 777 permissions if it does not exist yet
     // owner will be the user/group the PHP script is run under
     if ( !file_exists($dir) ) {
      mkdir ($dir, 0777);
     }
     if (isset($_POST['data'])) {
    
             $stringData = $_POST['data'];
             $file = "/var/www/devData/test/ciao.txt"; 
             $fh = fopen($file, 'r+') or die("can't open file");
             fwrite($fh, $stringData);
             $theData = fread($fh, filesize($myFile)); //this is the string that i have to pass
             fclose($fh); 
    
             echo $theData;  // <-- ECHO
    
     }
    
    
     ?>
    

    You have to OUTPUT the data, not return it. That is, echo it. If the string is not yet json encoded, use echo json_encode($theData);

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

how can i get the filesize from a string in php? I put the
I need to send a file from one PHP page (on which client uploads
I can't find out how to get some data from a PHP file across
I am trying to get data from a php file. This is my PHP
I'm using Fluent NHibernate and need to get my Connection String from the connection.connection_string
I need to get all substrings from string. For ex: StringParser.GetSubstrings([start]aaaaaa[end] wwwww [start]cccccc[end], [start],
I need to get string array or list with ajax and Action, this is
I have this string: 123-456-7 I need to get this string: 1234567 How I
I have just started PHP and mySQL and need to know if this is
I am preparing and sending a JSON string from my PHP file to my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.