Jump to content

Creating a file in FTP through PHP

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
Edvinas

Edvinas

    Newbie

  • Members
  • PipPip
  • 10 posts
Hello guys

I can't figure out how to create a file in my ftp using PHP. I want to make it so when someone registers on my website, a file with their username is created in certain folder, I've tried fopen:

fopen("ftp://hidden:hidden@hidden.com/public_html/somefile.txt", "w");

but for some reason it doesn't work, no errors what so ever but it just doesn't create the file.
I don't want it to create file in local directory and upload to ftp, no. What i want is for it to create the file straight in my ftp.

Any help appreciated!

#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
You're walking down a bad path using fopen like so, take a look at PHP's own FTP commands:
PHP: FTP - Manual

If you aren't willing attempt it yourself there is an easier class wrapping the functionality, there are lots more on the web:
PHP's FTP functions tutorial
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#3
Edvinas

Edvinas

    Newbie

  • Members
  • PipPip
  • 10 posts
Yay, I've done it. Thanks a lot :D