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

Bob Patin bob at patin.com
Sat Mar 7 16:22:44 MST 2009


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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: new_logo_idea3_120w.jpg
Type: image/jpeg
Size: 15728 bytes
Desc: not available
Url : http://mail.iviking.org/pipermail/fx.php_list/attachments/20090307/cf10f61d/new_logo_idea3_120w-0001.jpg
-------------- next part --------------


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



More information about the FX.php_List mailing list