[PHP] File open Question?
Can you open a simple text file and store each line of that file in it's own part of an array? -David Serrano -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] File open Question?
Ok, I think I get it, though I have one more question to access a specific line of that array would it just be as simple as $array[2]? -David Serrano "Brian Clark" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > if(! $array = @file('/usr/local/src/fdiff.c')) > die("can't read diff.c"); > > while(list($i,$line) = each($array)) > { >print "$i: $line\n"; > } > ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] File open Question?
Ok thats what I though. Thanks for your time -David Serrano "Brian Clark" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi David, > > @ 7:35:06 PM on 4/16/2001, David Serrano wrote: > > > Ok, I think I get it, though I have one more question to access a specific > > line of that array would it just be as simple as $array[2]? > > Yes. Otherwise these may be of some help: > > http://www.php.net/manual/en/function.fopen.php > http://www.php.net/manual/en/function.fgets.php > http://www.php.net/manual/en/function.fread.php > > > -Brian > -- > PGP is spoken here: 0xE4D0C7C8 > Please, DO NOT carbon copy me on list replies. > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: file upload problem - Warning: Max file size of 8 bytes exceeded
I'm not sure if you've read this or not but it may help: http://www.php.net/manual/en/features.file-upload.php -David Serrano ([EMAIL PROTECTED]) "Lee Philip Reilly" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi, > > I have an HTML form containing a file upload form object called 'file'. > When I submit the form (either holiding a path to a 1kb file or a 7MB > file) I get the following error: > > - > Warning: Max file size of 8 bytes exceeded - file [file] not saved in > Unknown on line 0 > - > > I had hoped that by changing the upload_max_filesize value in the > php.ini this problem would be resolved, but it hasn't. I expect some > people have had similar problems in the past; can anyone suggest what > the problem is? Some additional info at the foot of this message. > > Thanks in advance! > > - Best regards, > > Lee > > Windows 2000; PHP4; Apache V1.3 > > PHP.INI reads: > -=-=-==-=-=-=-= > ; Maximum allowed size for uploaded files. > upload_max_filesize = 8M > -=-=-==-=-=-=-= > > Simplified PHP script reads: > -=-=-==-=-=-=-= > if ($file!=""){ > @copy("$file", "c:\Program Files\Apache Group\Apache\htdocs\sasdap\v4" > or die ("Could not copy the file."); > } > else { > die("No input file specified"); > } > -=-=-==-=-=-=-= > > .HTML's file upload name = "file" > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: Slash Problems When Using PHP and POST.
Check out the stripslashes and AddSlashes functions http://www.php.net/manual/en/function.addslashes.php http://www.php.net/manual/en/function.stripslashes.php "Corin Rathbone" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I have created a php page that loads a file into a textarea. You can then > edit the file and click "Save" and it POSTS it to the same page (edit.php) > on the server. It saves it but it adds slashes before any speech marks (""). > Can somebody please help me with this. > > It changes: > > to: > > > Below is the code for the page edit.php: > include "config.php"; > > if(isset($save)){ > $fp = fopen("$file", "wb") or die("Could not open file!"); > $worked = fwrite($fp, $contents) or die("Could not write file!"); > fclose($fp) or die("Could not close file!"); > $edit=false; > $save=true; > } > elseif(isset($file)){ > $fp = fopen("$file", "rb") or die("Could not open file!"); > $contents = fread($fp, filesize($file)) or die("Could not read > file!"); > fclose($fp) or die("Could not close file!"); > $edit=true; > $save=false; > } > else{ > $edit=false; > $save=false; > } > > ?> > > > > > Edit A File - File Explorer For > > > > > > > > > Edit A File > > if($edit){ > print( "Contents Of file: " ); > print( "$file" ); > print( "\n" ); > print( "\n" ); > print( " \n" ); > print( " print( "$file" ); > print( "\">\n" ); > print( "" ); > print( " \n" ); > print( "$contents" ); > print( " \n" ); > print( " \n" ); > print( " \n" ); > print( "" ); > } > elseif($save){ > print( "\n" ); > print( "File: " ); > print( "$file" ); > if($worked){print( " has been saved!" );} > else {print( " has not been saved!" );} > print( "" ); > } > else { > print( "Please Select A File To Be > Save!" ); > } > ?> > > > > ©mailto:[EMAIL PROTECTED]";>Corin > Rathbone 2001 > > > > > Regards, > Corin Rathbone > www.corin.org.uk > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: include, chmod, password files
You could either rename the file with a .php extension or you can have it so the server treats .inc files like php files. "David Hill" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hello > > If I have a file called db.inc with, for example, this: > > // db.inc > $user = "david"; > $pass = "password"; > > ?> > > I have a my index.php do a include('db.inc'); > ok, that works. > > However, any user on the system can read db.inc cause its chmod'd 0644. > If I chmod db.inc 0600 or even 0640, index.php can not include it. > > How do I go about protecting my files from being read by users on the system? > > Thanks > - David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]