It opens the root folder, are you sure you have write permissions there? Perhaps you need to ftp_chdir to a different folder first.

It opens the root folder, are you sure you have write permissions there? Perhaps you need to ftp_chdir to a different folder first

Yes, theorically I should.

Its the root server to where I FTP with the user Im using all the time.

Should I chmod before it or something?

Besides, yes, I should; Remember the file is created but no content is inside.

Since you moved the uploaded file, it should be visible and readable on your server. Is it?

Its visible, meaning I see the file; As a matter of fact, the server is next to me, I see it appear in the explorer but when I open it, it is empty when on the local side, it has text inside.

Am out of ideas right now. When I'm home I can try your code.

Im reading the documentation but I really dont see the problem..........must be something small....

Am out of ideas right now. When I'm home I can try your code.

Thank you, Ill see them tommorow.

Well, Im going to continue to see what I can do with this.....

Did some conditional ifs and all of them return true....

<?php



                $name=$_FILES['file']['name'];








                $conn_id =  ftp_connect("127.0.0.1");

                $login_result = ftp_login($conn_id, "user","pass"); 

                ftp_pasv($conn_id, true); 





                if (move_uploaded_file($_FILES["file"]["tmp_name"],getcwd()."/".$name))
                    {
                        echo ("work");


                    }
                    else
                    {
                        echo ("doesnt work");
                    }



                $fp = fopen(getcwd()."/".$name, "w");

                if ($fp==false)
                {
                    echo ("problem opening file");
                }



                echo ("hi");
                fclose($fp);



                if (ftp_put($conn_id, $name, getcwd()."/".$name, FTP_ASCII))
                {
                    echo ("working correctly");
                }
                else
                {
                    echo("problem");
                }


                exit;

BTW, this has worked in the past FTPing to this server so....

Also, transfering the file with Windows Explorer works so its not a permissions issue....

We overwork pritaeas....

$name=$_FILES['file']['name'];
$conn_id = ftp_connect("127.0.0.1");
$login_result = ftp_login($conn_id, "user","pass"); 
ftp_pasv($conn_id, true); 
$upload = ftp_put($conn_id, $name, $_FILES['file']['tmp_name'], FTP_ASCII); 
exit;

Done.

Odd..........ftp_put gives me a warning that it cant created the file.

OK, a basic txt file created in Notepad gets transfered yet a text file created by Java doesnt.....

I hate this shit.

It gets weirder and weirder....

I had some simple text in the text file I created in Notepad. Lets say "The fox"

I am able to transfer that thru PHP and it creates the file with "The fox" inside

Now lets say a text file from Java says "The fox jumped over the fence". That doesnt transfer.

What I did is I copied that text from the Java one to the Notepad one and saved it. But when I transfer now the Notepad text file it just says "The fox jumped". Nothing else.

Why?

I can upload small texted file but not large ones....

Let me check for a limit...

Created by Java, is it perhaps a unicode file, or containing a BOM marker. If so, it maybe considered a binary file. Try FTP_BINARY, works on ascii files anyway.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.