Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Creating Text Files On The Fly


What I want to do is allow a logged in user to download a text file version of the list they are viewing on the screen. So if they are viewing the Paid list of users, there should be a button on that same page that says Download To Text File, and when clicked, the user is prompted to download a text file version of the list.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Creating Text Files..
I want to set my access rules to 0777 so that I can delete the text file via script if I need to. I already set the folder to 0777 when I created it.. now I just need the text files. How would I set the access to 0777 when I create the file? This is what I have right now...

$text= "this is text.";
$fileName = "examplefolder1/example.txt;
$handle = fopen($fileName, 'w');
fwrite($handle, $text);
fclose($handle);

Is there some way to do it in that statement?

Creating Dir, Copy Files And Pass Variables To 2 Files
I need to create a folder on the server weekly named by the user. To this folder copy the contents of an /Original folder. Inside the new folder edit one of the files to insert a data with a XML path generated in another application, copied (via memory) and pasted within the very first form and passed to the file in question.

<param name="FlashVars" value="xmlfile= $lanofile" />

the $lanofile is the value that I need to pass from the form to be read by this file.
I have created an form (n.php) that POST the name of the folder to a second file (creatdir.php) everything is cool until I have to edit the third file.

How can I pass the value of one of the formfileds to a second file and them read this value as a variable to be consumed as mentioned above? Or actually right whatever is on the third field to this position (not using variables).

Creating Files
I was wondering, if/how do you create a file with PHP, Im making a "network" for my site with PHP, and ran across this problem.

Creating Files
Is there a way to create files such as config.ini thoruhg a form. so they put in all the stuff they want and press submit and then the file is created with their settings in it.

Creating Files
I am rather new to PHP and a relative newbie to Linux too.
I have a webserver at home (Apache 2.0.48 on SuSe 9.0, PHP4).
I have some scripts, one of them needs to be able to create logfiles
somewhere on my machine. It must also later be able to read from and write
to these files again.

Sofar I get a permission error. I tried chmodding 666 or 777 the directory
in which the files could reside, to no avail.
How do I set up the permissions so that my script can simply fopen a file
for writing. Or if that's not the issue, what am I doing wrong or
overlooking ?

The errors:
Warning: fopen(logfileslog1.txt): failed to open stream: Permission denied
in script1.php on line 142
Warning: fwrite(): supplied argument is not a valid stream resource in
script1.php on line 154
Warning: fclose(): supplied argument is not a valid stream resource in
script1.php on line 161
It's the first I am puzzled about, the 2nd and 3rd are a logical
consequence.

By the way, reading from and writing to a file I have previously created
myself with exactly the names I tried to get created by the script (echoed
the name, ok) is no problem at all.
So I don't think it has much to do with a safemode or open_basedir setting.
I also tried creating the scripts in the same dir the script itself resides.
Did not work either.

Creating Files
I am currently creating a file manager to add/edit/delete files and folders, etc but i was wondering if there is a function in PHP to create files such as a php file or txt file? All i want is a function that will allow you to create a file from the name you give! Is this possible? I have seen a script called Genesis but the problem is that it is Perl! and i dont have a clue about Perl!

Creating Exe From Php Files
I know for a fact that is possible but can not figure it out, how can I get my application to an exe stand alone file?

Creating Images With Text
How can I create an image with some text in it so I can use a special font that wil be visible on each type of browser because it's embedded in a picture?

Creating And Saving Files With PHP
Hi, hope someone has some ideas !. Is there a way to use PHP and Mysql(if needed) in the following way: Lets say I used a script that when a person enters their birthday info, this script produces an onscreen report (like horoscope), how could this browser screen be saved as a file(html or other) so I could then include it into the body of an email or attach!.

Creating Csv Files From Scratch
I have a db containing customer information (ie. address, phone number, email). My client wants the ability to print mailers from the db. The idea is that the client will run searches on the db, and the search results will be dumped into a file which the client will download. The client will then give that file to their printer, to print the mailers.

The printer wants the file in csv format but I'm having trouble finding good info on creating csv files from scratch. Obviously part of the script will output the fields separated by a semi-colon, or some other delimiter, but I'm confused about how to define those fields. Does this make sense?

PHP Scripts And Creating Files
I have a PHP script that attempts to create a temporary file to be used
during processing. The script is owned by my username (bryanrme) on
the server. When the script attempts to create the temporary file, I
get a "failed to open stream: Permission denied" error. The
permissions on my directory are set to 755. When I set the permissions
to 757, the creation of the file is successful. In this case, I notice
that the script spawns a temporary file owned by a user named "99".

Is there any way to avoid this? I'd prefer not to leave my directory
set at 757, but is there any workaround for this? I checked my server
configuration and safe mode is not enabled. Any suggestions? I would
prefer that the script handle the creation, usage, and disposable of
the temporary file.

Creating Files Remotely
I'm trying to do here is write 2 files simultaneously to both the local server and a remote server on which I have write access. In the process, however, I was stuck at how to create the file initially on the remote server. I tried using touch() which works well locally to create a blank file, but I get an error:

Warning: unable to create file http://198.78.114.67/news/tech/20010718-1820.dat because No such file or directory in /home/httpd/html/makepost.php

well, I take it touch() only works locally, so, any idea guys?

Creating .m3u Files Dynamically
Im looking at creating a playlist program for my server.  i have alist of files within my database, and i wanted to be able to place these values into a playlist file.  the problem is that i dont know how to get the database to create the playlist form its records.  ie, if i uploaded a new file to my server and into the database, then i woudl want the script to automatically grab that file ( SQL  i know), anbd the nplace it in the m3u file ( i dont know).

Coudl someone recommend a simple method to complete this?  or point me in teh righ t doirection for a tutorial?

Creating A Variable From A Text File
I have a text file which is basically an array declaration and I would
like to assign this to a array variable.

It reads like this (extract)

myProfile = {
["Blackhand"] = {
["Fingali"] = {
["Inventory"] = {
["Bag4"] = {
["Contents"] = {
[1] = {
["Quantity"] = 1,
["Name"] = "Hearthstone",
["Color"] = "ffffffff",
["Tooltip"] = {
[1] = "Hearthstone",
[2] = "Soulbound",
[3] = "Unique",
[4] = "Use: Returns you to The Crossroads. Speak to an
Innkeeper in a different place to change your home location.",
},
["Item"] = "6948:0:0:0",
["Texture"] = "InterfaceIconsINV_Misc_Rune_01",
},
[2] = {
["Quantity"] = 1,
["Name"] = "Skinning Knife",
["Color"] = "ffffffff",
["Tooltip"] = {
[1] = "Skinning Knife",
[2] = "One-Hand",
[3] = "2 - 5 Damage",
[4] = "(2.2 damage per second)",
},
["Item"] = "7005:0:0:0",
["Texture"] = "InterfaceIconsINV_Weapon_ShortBlade_01",
},
[3] = {
["Quantity"] = 7,
["Name"] = "Cactus Apple Surprise",
["Color"] = "ffffffff",
["Tooltip"] = {
[1] = "Cactus Apple Surprise",
[2] = "Use: Restores 61 health over 18 sec. Must remain seated
while eating. If you spend at least 10 seconds eating you will become
well fed and gain 2 Stamina and Spirit for 15 min.",
},
["Item"] = "11584:0:0:1388764288",
["Texture"] = "InterfaceIconsINV_Misc_Food_19",
.....


I tried this

$lua = urldecode($lua);
$thefile = implode("", file($lua));
$arr = ${$thefile};

Creating And Deleting Folders And Files
Hi to Everyone.

After creating trought http a organize number of files and folders. I'm not able to delete them, not even trought an FTP Software like Cute FTP. It replies "Could not delete xxxxx.html".

Strategy For Creating Files And Then Cleaning Up
I'm using PHP 4.3. There is a section of my application in which I'd
like users to be able to download a custom file. The file would be
different for each user, so I was planning on creating it on the fly
when they click "Download". However, I would like to delete the file
from the server a certain period of time after they've downloaded it.
(It's a 3 or 4K file). How can I do this?

Creating Files Using Fopen That Are Unlocked!
i'm trying to setup my website to create new webpages dynamically using
php but I am have a major problem in that whenever i create a file it
is always created locked so that it can only be read even when i
specify read and write access.

Here is a basic example of the code I am using (I am using a Mac OSX
10.3.9):

<?php

$filename = '/Users/myusername/sites/mysitefolder/newfile.php'
$mytext = 'my text'

fopen($filename, 'w+');
fwrite($filename, $mytext);
fclose($filename);

?>

When i run this program all it does is create a blank file with
read-only access. My question is what settings do I need to change that
will enable me to create writable files using PHP?

Creating Text File With Page Breaks
If is a newline and is a carraige return, what special character is used for a page break?

Creating/writing To Text File And CHMOD
When I try to create a file with fopen(xxx.txt, w) I only receive an error message. Also when trying to append text to an existing file. I then chmoded the existing file to rw-rw-rw and it works now, but is this the right permission ? And how can I create a new file ?

Creating Download Manager For Multiple Files
Has anyone run across some sort of download manager to be able to download multiple files at a time via http with PHP? I run a mp3 site and I would like to be able to allow people to download whole folders at a time basically the same functionality as ftp but with http. It would be kind of like the smart download thing that netscape has but cross platform compatible. Any ideas?

Creating .xls And .doc Files With Page Breaks Using PHP / MySQL
Our company currently processes a few hundred form submissions through
our site. Up till now, the contents of the form has been sent to our
customer support staff in real-time. Each submission goes to a general
e-mail box where it's printed through our mail client. A copy of the
form is also stored in a MySQL db, although it's not used that often.

I have been asked to figure out a way to stop delivering the form
submissions in real-time and migrate to the following:

Each morning, provide an Excel spreadsheet and word document (or PDF)
with a certain number of form submissions to each customer support
rep. For example, say 200 form submissions were processed the day
before. This morning, I should split those 200 among the 5 support
reps and provide each of them a certain amount (which can change
daily). Assuming each person gets 40 form submissions, each person
would need to be given an excel file and .doc document that contains
their 40 form submissions.

One of the most important things is that the .doc file needs to have
each form submission separated by a page break, so that when they
print the document each form submission is printed on a separate page.

Finally, not all of the fields from the form submission should be
given to the support rep. Maybe date and time is left off.

Creating Files From An Array Using Fopen And Fwrite
I can make a script that works fine for creating files on a single row, but I can't get it to create the content of an entire array. Code:

Creating Temporary Table From Full-text Query
i'm using a full-text search on my db which works fine, but now i'm working on filtering the results further, like products in range of prices. my logic is to simply SELECT them out of the temporary table, only if it would be created. i don't think i need to paste any code since i think you get the idea.

Parsing Text Files
I have a little brain freeze going here. I can't remember how to do this.

I'm trying to parse a text DB file and seperate all information in it so that I can insert them into MySQL as seperate values in seperate fields. for example,

1 | howdy | there

That would be three peaces with three different fields in MySQL. I know I've done this before but can't for the life of me figure out how I did it. All I need is somebody to jog my memory and get that little brain of mine weorking again.

Extracting Text From PDF Files
I need to extract the text from a PDF file for storage in the database.
Is there a way to do this in PHP?...

Upload Text Files
Its only once you've got loads of content that you start filtering what people see based on their prefferences. To get lots of content you need to get people to upload text files which end up on web pages extending your site.

Cookie Text Files
I just added some cookies to my page, and they work fine, but I just wanted to know what the lines mean when I view the file in Notepad. PHP Code:

How Get Differences Between Text Files:
I have two text (configuration files) and I'd like to get the difference between these files.
I'd like something like "diff" in linux or differences in wiki.
how can I do?

Extracting Text From Pdf Files
with how to extract text from pdf files using PHP or
ColdFusion?

Uploading Text Files
I'm somewhat new to this whole MySQL/PHP thing and need a little help.

My web hosting service uses phpMyAdmin and at the bottom of the screen
iis an area where I can upload a text file to populate a table.

I have a table named groups with two fields:
groups_idauto-increment primary
groups_name

So how do I create my text file to populate this table?

I'm going to use MS Notepad.

If it's set to auto-increment, do I need to include the number? If
so, does it start at 0 (zero)?

Would the file look like:

0,students
1,faculty
2, staff

or just

students
faculty
staff

(though I can't image that working).

Text Files Hit Counter
I have a script that I am using for text file based hit counter. I have been noticing that my the original hit count, in my text file has been fluctuating from the original amount to a very low amount. What is causing this and is there a good way to fix it? Code:

Create Different Text Files
I need to create a different text file every time a user registers. Currently every time a user registers there details are sent to "users.txt". So all user details are in the same text file. I would idealy like each text file to be named after the username registered. Here is the code currently being used:

$username = $_POST['username'];
$password = $_POST['password'];
$data = "$username, $password /n";

$fh = fopen("users.txt", "a");
fwrite=($fh,"$data");
fclose=($fh);

Text Files Into Array
I'm trying to read a text file that has a bunch of names in it into an array so that I can output that array to a comma separated format. My problem is this, I do not know how to make a file go into an array, I've tried the explode function, but all that does is spit out  "Resource ID"

the format of the file is "1. FirstName LastName" with line breaks so the next line is "2. NewFirstName NewLastName", and so on...

Indexing Text Files In A Folder
I'm newbie on Php. I cannot write codes but only modify.
I need a code doing this:
I'll put text files in a folder like file1.txt,file2.txt ...
I want to search this files, list most recent 10 and if files

call, script will put into the site design with <pre> tags.

PHP - MySQL - Text Files - Speed
I've got a question that I'm sure is answered somewhere but I haven't run across it yet.

I've got a site with a lot of content that's being pulled from a database. Most of the content changes on a very regular basis.. I take it, push it into some templates, and render it to the screen.. pretty standard stuff..

But some of the pages have large blocks of static content. Just as an example, lets take about 50 lines of formatted static HTML.

This content doesn't change very often at all. The site is already designed to push through a template, so putting the content into static HTML pages isn't an option. The question is, should I store that content in MySQL or in a text file?

I figured that MySQL would be easier on the system. The fetches seem like they would be pretty easy for MySQL to handle, no complex queries. I figured that pulling from a text file would require apache/php to open the file, read the file and then close the file every time someone hit that page.

Am I putting unwarrented stress on our database?

Questions On Merging Two Text Files....
I will have a form field that will allow one of two text files to be uploaded to the db. This text file will have sections that are defined something liek this;

Opening All Text Files In A Folder
Im very new to php and need a bit of help. basically what I have is a folder with a number of text files inside. What i need to do is open every text file in that folder and then process the information inside each text file.

Im not really sure but I would assume I open the directory and place the name of each text file into an array and then loop through the array and process the contents of the text file.

#open directory

#foreach text file in the directory
#store file name into an array

#loop through array
#process code

Php Template For Multiple Text Files
I have over 800 text files. I need one php template webpage that can pull in text of requested file on request in url. Example:

http://www.gothinia.com/chronicle/epos.php3?title=Title_Of_Text_File_With_Story.txt

would place text of Title_Of_Text_File_With_Story.txt inside template called epos.php3
what code will do this in a simple effiencient manner?

Changing Data In Text Files
Is there an easy way in which I can edit values in a text configuration file? I am creating a form based interface to administrate a few text based config files. I can get the values from the file by parsing it line by line, but I cannot find an efficient way to edit data based on changes submitted in the php form. Is there any way to get to a position in a file and then overwrite any information?

Opening Text Files And Storing Them In A DB
I have a directory full of text files I need to open and store in the DB..... My question is about the file system stuff... I wanna open all files in a directory one by one is there a way to do a while loop of the files?

Includes And Writing To Text Files
i have 6 scripts, each writing to a text file.  in addition, i have an index file with links to all the text files that includes all of these scripts.  the problem is that the index file will run one script off the include list and then stop.  it's incredibly bizarre to me and i'm not sure why it's happening.

Reading Variables From Text Files
I am playing with several text files that have variables stored in two different ways. One text file stores the data like this:

hair=brown
eyes=green
gender=male

The other text file stores data like this: hair=brown&eyes=green&gender=male
How can I read the variables from the text file and use them in my php program? I know how to write them to a text file, but have no clue as how to read them.

Using PHP Offline To Manipulate Text Files
I need to create an application that will do fairly simple text manipulation
on 20,000 files in text format (html files). The files exist both on my
Windows machine and on a FreeBSD server. I prefer to do the manipulation on
my machine where it's easier to create backup copies, recover from
programming errors and so on, then upload the files to the server. All I'm
doing is extracting certain elements from each file and creating a different
file with the same content that will look better. I could do this in
FrontPage (or even Notepad) if I didn't have 20,000 files, so I need to
write an application that go through each file in a directory, open it,
locate the relevant text elements and create a new file that has these text
elements in an appropriate format.

I'm comfortable that I can write an application like this in PHP, even
though I do not have PHP installed on my computer, which is a Windows box
and is not being used as a server. Does this make sense? Can I install and
use PHP for this purpose without lots of server-related baggage?

Storing Classes In Text Files
is there a way to store class in a text file? and then recall thjem? and is there a better way to store variables and such than a text file, so its unreadable?

what i mean abou my question is.. is it possible to make two classes: User1 and User2, and then recall them so you can get User1.password and User2.password, User1.ID, User2.ID, etc.

Align Text And Searching Files
i would like to align my following code so that it sets it to the left side of the ;page. ive tried a few things but didnt work. also i would like to have it so that it only searches for picture and movie files. how would this be accomplished? Code:

Comma Separated Text Files
A client has requested that I make a php app which takes an uploaded image, reads the values and enters them into a database. I've made the upload script which works fine, and the script which enters the values into the database, the only thing left now is how do I make PHP read the file and extract the values? The file is a text file, each field comma separated.

Grabbing Text From Files/strings/etc
Wondering how to grab pieces of text from a file. Let's say I opened a webpage and want to have all the values of the input fields. This would be the contents of the file

<html>
<head>
...
</head>
<body>
...
<input type='hidden' name='hidden_w' value='123456' />
...
</body>
</html>

Now I want that value of the input field 'hidden_w' to be in the variable $w.
How do I this?

Editing And Handling Vars From Text Files
I have a config file like that

a=12
b="some other values"

I want to handle these vars for my php program and also be able to edit these vals.

Open, Search, And Process Other (text) Files
How could I use php to open, read, and perform operations on a file?

Say I wanted to open somefile.htm and search for instances of <p class="one">Foo</p>, strip the tags, then put 'Foo' in a variable called $foo... Is this doable?


Copyright © 2005-08 www.BigResource.com, All rights reserved