Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Zhapness · May 02, 2011 at 11:09 AM · serverreadftp

How to write/read .txt on FTP (Javascript)

Hi I want to be able to Write and Read files from my ftp server.

I have my scripts set up to do what i want but only localy.

Here is what i use:

import System; import System.IO;

var PropertyNumber : String ="PropertyNumber"; var PropertyOwner : String = "Nobody";

function Update () { if(File.Exists("PlayerInfo/Property"+PropertyNumber+".txt")) {
var si = File.OpenText("PlayerInfo/Property"+PropertyNumber+".txt"); var line = si.ReadLine(); PropertyOwner=line; } }

This works but i cannot just write any url in the File.OpenText("") It only works localy for now.

I just need to know how to connect to my ftp server.

I also need to be able to write txt files on my server.

Any help welcome!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Zhapness · May 04, 2011 at 05:42 PM

Do you know anything about FtpWebRequest?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Kourosh · May 02, 2011 at 11:34 AM

I'm not if you can write on a txt file on your ftp server directly from your application. It requires you to login first. My suggestion is to write a php cgi and place it somewhere on your webserver and then using a form in unity submit your data to that php which will then write it to a text file for you.

Here is how to write the PHP
http://www.tizag.com/phpT/filewrite.php

Here is how to create the wwwform in unity. http://unity3d.com/support/documentation/ScriptReference/WWWForm.html

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Zhapness · May 03, 2011 at 10:17 AM 0
Share

Thanks i hope ill get it after some reading, first attempts where unsuccesssfull.

avatar image
0

Answer by Zhapness · May 03, 2011 at 12:16 PM

hmm.. have been trying to do this for 3 hours now, somebody should make a guide for this damn.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Kourosh · May 03, 2011 at 02:07 PM 0
Share

I assume you have problem writing the php. Here's another link for writing the php.http://www.codingforums.com/showthread.php?t=47311 I'm not sure how familiar you are with posting a html form to a server-side script. You can understand the concept here:http://www.tizag.com/phpT/forms.php What will change in your case is that ins$$anonymous$$d of making the html form you'll use unity to create the form for you and the post to the server-side script(the php I mean).

avatar image Zhapness · May 03, 2011 at 11:47 PM 0
Share

Thank you allot i will look into this tomorrow.

avatar image Zhapness · May 04, 2011 at 05:15 PM 0
Share

Omg this is killing me xb

avatar image Zhapness · May 04, 2011 at 05:18 PM 0
Share

var URL= "http://www.$$anonymous$$YSIT$$anonymous$$com/gameData/cgi.php";

function OnDisconnectedFromServer(info : NetworkDisconnection) {
if(networkView.is$$anonymous$$ine) { var form = new WWWForm(); form.AddField("x position"transform.position);

     var w = WWW(URL, form);
     yield w;
     if(w.error !=null)
     {
         print(w.error);
     }
     else
     print("Finished uploading position");
     
     
     Network.Destroy(gameObject);
 }

}

It does nothing, i dont know any php at all, i will need a specific example to understand and use it.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

I cant read the file i wrote, unless i reload it in VS. 1 Answer

Unity networking tutorial? 6 Answers

FTP Upload Files 2 Answers

Dat File Location 1 Answer

How to make/write to files, then read immediately? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges