Re: [PHP] Re: ftp_put()'ing a string ...

2006-07-12 Thread Jochem Maas
Jake Gardner wrote:
 An intriguing method, but then it is the only answer I can think of
 (when I see it above) to what you must admit is a rather odd question...

what is it that you consider odd?
I have a generated string containing XML and I want it to end up on
a remote server as a file - it would be easy enough to write the string
into a tmp file in order to transfer that but I thought it would be nice
to not have to make the extra hit to the filesystem to get the job done.

I think I have figured out how to get some useful error messages using the
'notification' streams context parameter (using it to set a callback that traps
notifications including error messages);

 nonetheless... if it is only the FILE writing that you care about
 without using ftp functions, one (not the most efficient way, but who
 gives a crap about a few seconds these days in a language like PHP?) use
 the ftp functions to test everything up to the write (connect, login,
 change directory, do everything right up to writing and then plug in
 your lines)

not only inefficient but wrong: it would possibly result in a duplicate
connection (which the ftp server may not allow) and if you closed the first
connection first then you still have no garantee that the second connection
via the streams wrapper actually did it's job.

anyway thanks for the feedback.

 On 7/11/06, *Jochem Maas* [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED] wrote:
 
 Jochem Maas wrote:
  hi everyone,
 
  I was wondering if anyone knew how (if possible) I could take a string
  and ftp_put()/ftp_fput() that string directly onto the remote
 server as a file
  (without first saving the string to disk temporarily locally)
 
  I imagine that there is a way to create a stream that refers to
 the string
  in question but I can't get my head round the streams functionality...
 
  Obviously saving the string temporarily to disk locally is an easy
 option
  but I was kind of using the situation I have now to try and do
 something a
  little fancy and learn something about streams.
 
  anyone with idea/pointers?
 
 I stumbled accross the following page while RTFMing:
 
 http://php.net/manual/en/wrappers.ftp.php
 
 very nice, it enabled me the come up wth the following to lines
 (nice and compact!):
 
 $context = stream_context_create(array('ftp' =
 array('overwrite' = true)));
 $retval  =
 file_put_contents(ftp://{$ftp_user}:[EMAIL PROTECTED]:21/{$filename},
 $xml, LOCK_EX, $context);
 
 BUT this leaves me with the problem of determining what went wrong
 if the file_put_contents() call
 fails. did the connection fail? did the login fail? did the
 write/upload fail (and why)?
 
 using the std. ftp functions it's [obviously] alot easier to
 determine at which point the failure
 occured. can anyone confirm I'm on the right track by trying to set
 'notification' [stream]context
 parameter?
 
 
  TIA,
  Jochem.
 
 
 --
 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] Re: ftp_put

2002-09-05 Thread victor

Ok, I'm having the same problem, see I use a form to upload but I guess
that it puts the file in temporary file, so with copy or something it
figures automatically where to take th file from how do I get the $
source and ft_put to figure out where to take this file from, or can I
get it to take it directly from the users computer through form?


- Victor  www.argilent.com

-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, September 05, 2002 9:34 PM
To: Jason Romero
Cc: [EMAIL PROTECTED]
Subject: [PHP] Re: ftp_put

I am having problems getting the ftp_put command to upload a file to an
apache server
i get this error
Warning: error opening
C:\\WINDOWS\\Desktop\\Jason\\jjmckay\\testaudio.mp3
in /home/virtual/site31/fst/var/www/html/clientadmin/mp3upload.php on
line
32

here is the code

$dest = /var/www/html/public/$user/;
$upload = ftp_put($FTP, $dest, $source_file, FTP_BINARY);

if ($upload) echo it worked;
else echo it didnt work;


the $source_file is pulled from a form on the previous page

Need more source code to tell you exactly where, but it looks like
you're
trying to have PHP suck in the original file name rather than the
uploaded
file.

You can't do that.

If you could, PHP could be used to steal *ANY* arbitrary file off of
*ANY*
computer.  Major security problem.

-- 
Like Music?  http://l-i-e.com/artists.htm


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

__ 
Post your free ad now! http://personals.yahoo.ca

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php