Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Kastenessen · Jun 22, 2016 at 10:49 AM · serverremoteuploadbinaryftp

FTP Uploading from Pc or Device, permissions, rejected by remote machine.

Hello,

For a client I require to be able to upload via ftp or url somehow to a server.

I have setup the server with an ftp server and have a heap of code I've been trying to work on to get it to upload a file successfully, either from my pc or from a device.

I save the file first with binary serializer:

   try
        {

           Stream stream = File.Create(Application.dataPath + @"/" +  nameOfFile + ".txt");
           BinaryFormatter bformatter = new BinaryFormatter();
           bformatter.Serialize(stream, resultsInfo);
           stream.Close();
                 
       }
           catch (UnauthorizedAccessException)
        {
                     print("SAVING ERROR!!!");            
        } 




Which is nice and simple and cut down and works. Then I use this to try and upload it to my ftp client:

       ftpRequest = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftp + nameOfFile + ".txt"));
       ftpRequest.Method = WebRequestMethods.Ftp.UploadFile;
       ftpRequest.UsePassive = true;
       ftpRequest.UseBinary = true;
       ftpRequest.Credentials = new NetworkCredential(creds0, creds1);
 
 
       FileInfo finfo = new FileInfo(Application.dataPath + @"/" + nameOfFile + ".txt");
       byte[] fileContents = new byte[finfo.Length];
 
                 
                 using (FileStream stream = finfo.OpenRead())
                 {
                     stream.Read(fileContents, 0, Convert.ToInt32(ff.Length));
                    // done = true;
                 }
 
                 using (Stream writer = ftpRequest.GetRequestStream())
                 {
                     writer.Write(fileContents, 0, fileContents.Length);
                 }
 


Which is some code I have borrowed from unity answers somewhere to try to help me understand how this works and get it to work lol. (if you cant make it fake it lol).

It gives me an error and freezes up. The error is that its rejected by the other machine.

I feel I am close to getting this. Would it be permissions somehow? Is there something I have to do with my remote server?

Would like to find a solution, I've been working long hrs to try to work this out as networking is a big subject and I am only just getting into it now.

Please help. Cause I am not sure what I am doing when it comes to networking and ftp's and the such.

Comment
Add comment · Show 1
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 Kastenessen · Jun 22, 2016 at 01:33 PM 0
Share

This is my error msg:

SocketException: No connection could be made because the target machine actively refused it.

System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP, Boolean requireSocketPolicy) System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) System.Net.FtpWebRequest.OpenControlConnection () Rethrow as WebException: Unable to connect to remote server System.Net.FtpWebRequest.OpenControlConnection () System.Net.FtpWebRequest.Process$$anonymous$$ethod () System.Net.FtpWebRequest.ProcessRequest ()

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Kastenessen · Jun 23, 2016 at 02:20 AM

Okay, so the permission's rejected thing is to do with the remote server not having an accessible user account setup in the ftp server.

So once my friend help me with understanding how to do that, I was able to get past that error by setting up my remote server users and allowing access rights (read and write and create dir and all).

And was then later able to solve the syntax error I had and that's in another question if anyone wants to look.

http://answers.unity3d.com/questions/1206839/syntax-501-error-how-to-upload-without-error-to-ft.html

All done, it now uploads to my ftp server not a problem.

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

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

60 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

WebGL Build WWW class : Unknown Error 1 Answer

How to Upload File on Blob Storage using Sas URI ? 0 Answers

Unity, WebClient, Upload, Async and Threads. 0 Answers

Upload image from IOS gallery show no search result but works find in Android 0 Answers

PlayerInitEngineGraphics: GPU not supported; OpenGL 2.0 is required. (After cuda installation) 0 Answers


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