Re: [PHP] appending to a file using ftp functions
Giulio wrote: Hi, I'm developing an application that uploads file to a server using http. the app calls a php on the server sending all the data just like a web form post. It works just fine uploading little files, now i'm concerning about having the apllication split large files in little chunks ( about 256 KB os so ) and sending them with multiple post. Wanna do that to avoid possible problems with php temporary files max size. No problem on the client side ( is sends the form with some info and the firts chunk, waits for server response and then repost a form with succesive chunk of file, and so on ), and also on the php side should be quite easy to store a file with the first post, and keep on adding to it the subsequent chunks of file posted, at least using the filesystem functions. My problem is that I'm using, to make the system as general as possible, and make it work even on servers where php doesn't have write privileges, ftp functions instead of filesystem functions, and using ftp it seems that it's not possible to append to a file. I also thinked to use the fopen function with an ftp address, but reading the docs it says that fseek function ( to position the pointer at eof to go on appending ) may not work if the file is opened using ftp or http. Suggestion about this issue? ftp_put() has startpos parameter. I think you need to turn FTP_AUTOSEEK off, because you have only partial file. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] appending to a file using ftp functions
Marek, thank you for your answer, Il giorno 27/apr/05, alle 1:28 PM, Marek Kilimajer ha scritto: Giulio wrote: My problem is that I'm using, to make the system as general as possible, and make it work even on servers where php doesn't have write privileges, ftp functions instead of filesystem functions, and using ftp it seems that it's not possible to append to a file. I also thinked to use the fopen function with an ftp address, but reading the docs it says that fseek function ( to position the pointer at eof to go on appending ) may not work if the file is opened using ftp or http. Suggestion about this issue? ftp_put() has startpos parameter. I think you need to turn FTP_AUTOSEEK off, because you have only partial file. I see... but startpos was added on 4.3.0, that's why I did't find it on my ( quite old, now i realize ) manual. do you think that i should use it and be confident that php 4.3 is at the moment widely installed? Regards, Giulio Cantoberon Multimedia srl http://www.cantoberon.it Tel. 06 39737052 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] appending to a file using ftp functions
I tryied using ftp_put() with startpos parameter, but I receive an error Appen/Restart not permitted, try again I tryed both FTP_AUTOSEEK on and off, and both pasv true and false I imagine that this is an ftp server error message, and not a php error, since I have searched it on php documentation with no success, is startpos option depending on the ftp server supporting append commands? Il giorno 27/apr/05, alle 1:56 PM, Giulio ha scritto: ftp_put() has startpos parameter. I think you need to turn FTP_AUTOSEEK off, because you have only partial file. I see... but startpos was added on 4.3.0, that's why I did't find it on my ( quite old, now i realize ) manual. do you think that i should use it and be confident that php 4.3 is at the moment widely installed? Regards, Giulio Cantoberon Multimedia srl http://www.cantoberon.it Tel. 06 39737052 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] appending to a file using ftp functions
Giulio wrote: I tryied using ftp_put() with startpos parameter, but I receive an error Appen/Restart not permitted, try again I tryed both FTP_AUTOSEEK on and off, and both pasv true and false I imagine that this is an ftp server error message, and not a php error, since I have searched it on php documentation with no success, is startpos option depending on the ftp server supporting append commands? yes, it is. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] appending to a file using ftp functions
Giulio wrote: I tryied using ftp_put() with startpos parameter, but I receive an error Appen/Restart not permitted, try again http://www.proftpd.org/docs/faq/linked/faq-ch4.html#AEN408 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Appending to a file
On Wed, Jul 10, 2002 at 12:45:01PM -0400, Chris Earle wrote: I'm just curious if there's a function that allows you to see how many lines there are in a file. I don't recall there being one. Simple way: $Array = file('file.name'); echo count($Array); --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Appending to a file
or use the unix command wc $num_lines = `wc -l $file`; Martin -Original Message- From: Analysis Solutions [mailto:[EMAIL PROTECTED]] Sent: Thursday, July 11, 2002 2:13 PM To: PHP List Subject: Re: [PHP] Appending to a file On Wed, Jul 10, 2002 at 12:45:01PM -0400, Chris Earle wrote: I'm just curious if there's a function that allows you to see how many lines there are in a file. I don't recall there being one. Simple way: $Array = file('file.name'); echo count($Array); --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Appending to a file
Thanks again for this response. The computer is a Win2k server. Thanks for the tips. :) Martin Towell [EMAIL PROTECTED] wrote in message 6416776FCC55D511BC4E0090274EFEF508A5FE@EXCHANGE">news:6416776FCC55D511BC4E0090274EFEF508A5FE@EXCHANGE... or use the unix command wc $num_lines = `wc -l $file`; Martin -Original Message- From: Analysis Solutions [mailto:[EMAIL PROTECTED]] Sent: Thursday, July 11, 2002 2:13 PM To: PHP List Subject: Re: [PHP] Appending to a file On Wed, Jul 10, 2002 at 12:45:01PM -0400, Chris Earle wrote: I'm just curious if there's a function that allows you to see how many lines there are in a file. I don't recall there being one. Simple way: $Array = file('file.name'); echo count($Array); --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] appending to XML file before closing tag
On Tuesday, June 25, 2002, at 08:42 PM, Brian White wrote: I was actually thinking about this the other day - every now and again I find my self yearning for SGML, where you could have just declared the wrapping element end tag omissable, and then you would never have to worry about it - basically the end of the file would imply the existence of the end tag (sigh ) Yes, but that makes parsing very difficult -- if you're expecting to find a closing tag, it should be there. You'd have to write a special set of XML-handling functions or a special library to cover this unique breach of the XML rules, since most XML modules (for Perl, PHP, Python, Java, whatever) expect well-formed documents. XML is pretty verbose, yes, but the rewards of this are consistency -- as long as the document is well-formed, it should be pretty easy to extract the data from it without writing special code to handle these kinds of exceptions. Erik Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] appending to XML file before closing tag
rantmode Hey - if you read my post a little more carefully you would see that I was bemoaning the effective passing of *SGML*. I was on a nostaligia trip. I am well aware that SGML is a bit of a complicated beheamoth, but it you have a decent SGML parser ( such as Omnimark or SP) you could do some really funky things. XML is a very cut down version of SGML that requires much simpler tools to process, but every now and again that simplicity will come back to bite you and make your life more difficult. This was one case of that. Most of the time I am quite happy to put up with the verbosity. /rantmode At 23:24 26/06/2002, Erik Price wrote: On Tuesday, June 25, 2002, at 08:42 PM, Brian White wrote: I was actually thinking about this the other day - every now and again I find my self yearning for SGML, where you could have just declared the wrapping element end tag omissable, and then you would never have to worry about it - basically the end of the file would imply the existence of the end tag (sigh ) Yes, but that makes parsing very difficult -- if you're expecting to find a closing tag, it should be there. You'd have to write a special set of XML-handling functions or a special library to cover this unique breach of the XML rules, since most XML modules (for Perl, PHP, Python, Java, whatever) expect well-formed documents. XML is pretty verbose, yes, but the rewards of this are consistency -- as long as the document is well-formed, it should be pretty easy to extract the data from it without writing special code to handle these kinds of exceptions. Erik Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] - Brian White Step Two Designs Pty Ltd Knowledge Management Consultancy, SGML XML Phone: +612-93197901 Web: http://www.steptwo.com.au/ Email: [EMAIL PROTECTED] Content Management Requirements Toolkit 112 CMS requirements, ready to cut-and-paste -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] appending to XML file before closing tag
On Tuesday, June 25, 2002, at 09:31 AM, William S. wrote: I know I need to introduce: fread() and fseek(). but not sure how to put it all together. If you know for a fact that the ending tag for each file is consistent and always that same tag, here's an idea. Determine or specify the length of the ending tag (in other words /html would be a length of 7 [characters]). Now move your file pointer to (file's total characters - length) so that it is immediately before the ending tag. Append your data, then manually append the ending tag. If you will deal with varying ending tags, then you'll have to come up with a creative method for capturing them and storing them, then dynamically determining their length and do the same thing, then append the ending tag (whatever it may be). I would use regexes to do this part. Erik Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] appending to XML file before closing tag
Yes, that worked. Nice and effective solution. Thank you. On Tue, Jun 25, 2002 at 09:51:21AM -0400, Erik Price wrote: snip If you know for a fact that the ending tag for each file is consistent and always that same tag, here's an idea. Determine or specify the length of the ending tag (in other words /html would be a length of 7 [characters]). Now move your file pointer to (file's total characters - length) so that it is immediately before the ending tag. Append your data, then manually append the ending tag. snip -- Bill Amsterdam, NL -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Appending url to file name...
On Monday, April 8, 2002, at 11:09 AM, Jas wrote: Ok this is an unusual problem, at least to a newbie like myself... I am trying to develop a user form to select an image from a directory by use of a select box that once the item is selected it will put that selection into a db field and this part I have working fine, however now I will need to be able to do something which I am not entirely clear on where to start... 1- I need to have the selection append the file path to the selected file... i.e. http://localhost/images/file_name.jpg, so far it only puts file_name.jpg into the database table. If you already know that the file will always be in the same directory, you could just prepend the string http://localhost/images/; to the query result in your query -- SELECT CONCAT('http://localhost/images/', tablename.image_name) AS image_name FROM tablename Or, if each file may have a different path, check out the dirname() function -- http://www.php.net/manual/en/function.dirname.php I think that you will have to add http://virtualhost; in any case, as this is a component of a URI and not a part of the file's path (and will not be automatically generated by dirname() or any other function that I know of). Erik Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Appending url to file name...
So putting it into an UPDATE statement it would be something like this right? UPDATE CONCAT $table_name SET ('http://localhost/images') ad01=\$ad01\; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Appending url to file name...
On Monday, April 8, 2002, at 11:35 AM, Jas wrote: So putting it into an UPDATE statement it would be something like this right? UPDATE CONCAT $table_name SET ('http://localhost/images') ad01=\$ad01\; No, like this: The table is named test_table The column you want to add this to is named test_column You are taking the data that test_column contains, and prepending http://localhost/images; to the beginning of that data: UPDATE test_table SET test_column = CONCAT('http://localhost/images', test_table.test_column) Warning: This command will change every single row in your table so that 'http://localhost/images' will be prepended before whatever data is already in that row. You probably want to make ABSOLUTELY SURE that this is what you want (are you sure you don't want a trailing slash in that CONCAT function?). If you want to just test this out, or don't want to apply this change to EVERY row, you can add a WHERE clause to choose certain rows to update. Keep in mind that test_column must be able to accommodate the new string (so you might need to make it a bigger VARCHAR or something). Good luck, Erik Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Appending url to file name...
Actually, I tried it a different way and I got the results I needed... this is what I did, $file_var = http://www.bignickel.net/full_ad/;; $db_name = db_name; $table_name = table_name; $connection = mysql_connect(localhost, user_name, password) or die (Could not connect to database. Please try again later.); $db = mysql_select_db($db_name,$connection) or die (Could not select database table. Please try again later.); $sql = UPDATE $table_name SET ad01_t=\$file_var$files\; //this gave me the results, as you can see I just created a new variable with the path in it print $sql; $result = mysql_query($sql, $connection) or die (Could not execute query. Please try again later.); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Appending url to file name...
On Mon, 8 Apr 2002, Jas wrote: $sql = UPDATE $table_name SET ad01_t=\$file_var$files\; Is this really what you wanted? It would set ad01_t to the same thing for every single row in your table. If that is what you wanted, then I think your database design is a little weird. miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php