[FX.php List] [OFF] PHP question: Pulling in text from a file

Head Honcho headhoncho at customikesolutions.com
Sat Mar 7 16:33:03 MST 2009


Hi Bob,

Perhaps you're really looking for fopen ( string $filename , string  
$mode [, bool $use_include_path [, resource $context ]] ) [fopen()  
binds a named resource, specified by filename , to a stream.]

Which then can be manipulated.

php.net is your friend


On 08/03/2009, at 10:22 AM, Bob Patin wrote:

> Well, I got it to work now, but I don't know what's different...  
> here's what I'm using:
>
> copy ($_FILES['file1']['tmp_name'], "/Library/WebServer/Documents/ 
> yada yada yada/".$_FILES['file1']['name']) or die ('Error.');
>
> $filename = $_FILES['file1']['name'];
> echo $filename."<br><br>";
>
> $string = file_get_contents("uploads/".$filename);
> echo strlen($string);
> -------
>
> Now it's working... since I kept blowing away all the code that  
> didn't work, I don't know now what I've changed, other than perhaps  
> I had the assignment to $filename wrong perhaps.
>
> Anyway, this works fine...
>
> Jonathan, to answer your question: I want to read in a file (they'll  
> actually be XML) and then parse it into a FileMaker record.
>
> Best,
>
> Bob Patin
>
>
> <new_logo_idea3_120w.jpg>
>
> Longterm Solutions
> bob at longtermsolutions.com
> 615-333-6858
> http://www.longtermsolutions.com
> iChat: bobpatin
> AIM: longterm1954
> FileMaker 9 Certified Developer
> Member of FileMaker Business Alliance and FileMaker TechNet
> --------------------------
> FileMaker hosting and consulting for all versions of FileMaker
> PHP • Full email services • Free DNS hosting • Colocation • Consulting
>
> On Mar 7, 2009, at 4:28 PM, Leo R. Lundgren wrote:
>
>> Bob,
>>
>> If you haven't already, read http://www.php.net/manual/en/features.file-upload.post-method.php 
>>  . It contains information on how to handle uploaded files on the  
>> PHP side. It also hints on what you need on the client side.
>>
>> In short the uploaded file is stored on the server in a temporary  
>> location. From there you can for example move the file to a  
>> permanent location, or you should be able to read the contents of  
>> the file, for example by file() which reads the file into an array  
>> where each element is one line, and returns this array, or  
>> file_get_contents() which reads the entire file and returns a string.
>>
>> Actually there is some more to the issue information at http://www.developershome.com/wap/wapUpload/wap_upload.asp?page=php4 
>>  (just the first page on the result when I googled), you might want  
>> to check that one first!
>>
>> Cheers.
>>
>>
>> 7 mar 2009 kl. 23.15 skrev Bob Patin:
>>
>>> I'm trying to do this: select a file, have PHP read in the text  
>>> and put it into a variable.
>>>
>>> I'm using a form, and have tried several enctypes; right now I'm  
>>> experimenting with "text/xml" with no luck.
>>>
>>> Question: does anyone know how to take a POSTed file and read it  
>>> into a variable?
>>>
>>> here's what I've got so far:
>>>
>>> $postText = trim(file_get_contents('php://input'));
>>> echo $postText;
>>>
>>> Getting nothing back...
>>>
>>> Anyone help?
>>>
>>>
>>>
>>> Bob Patin
>>>
>>>
>>> <new_logo_idea3_120w.jpg>
>>>
>>> Longterm Solutions
>>> bob at longtermsolutions.com
>>> 615-333-6858
>>> http://www.longtermsolutions.com
>>> iChat: bobpatin
>>> AIM: longterm1954
>>> FileMaker 9 Certified Developer
>>> Member of FileMaker Business Alliance and FileMaker TechNet
>>> --------------------------
>>> FileMaker hosting and consulting for all versions of FileMaker
>>> PHP • Full email services • Free DNS hosting • Colocation •  
>>> Consulting
>>>
>>> _______________________________________________
>>> FX.php_List mailing list
>>> FX.php_List at mail.iviking.org
>>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>
>> _______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list

Regards

Michael Ward
--
Head Honcho
CustoMike Solutions
Member, FileMaker Business Alliance
Member, FileMaker Technical Network
FileMaker 7 Certified Developer
FileMaker 8 Certified Developer
FileMaker 9 Certified Developer
10 Wandoo Crt
Wheelers Hill, 3150
ph 0414 562 501
headhoncho at customikesolutions.com





More information about the FX.php_List mailing list