Updated as per Use-Policy: https://sourceforge.net/p/forge/documentation/Project%20Web%20and%20Developer%20Web/#outbound-connectivity
Due to past abuse, outbound access to other hosts from the web servers
is strictly prohibited, and is blocked by firewall rules. This
includes access to other SourceForge.net hosts; the only exceptions to
this policy are access to our project database servers and authorized
outgoing emails. SCM server access is not available from the project
web servers. Any content needed from other SourceForge.net hosts
should be retrieved and stored as a file or database entry that may
then be accessed from scripts on the project web servers. While our
PHP install (and other languages) include support for things like
LDAP, IMAP and Postgres, we do not permit inbound or outbound
connectivity using these protocols. These components are included so
third-party code may be kept stock when being deployed on
SourceForge.net web servers; and to support the testing of project
code which requires these functions.
So the ability to connect to external hosts is blocked by a firewall and is not possible.
Please post your phpinfo()
output in your question. Specifically the system details (top section), core, curl, sockets, and standard section values (leave out any confidential info like database passwords/connections).
There are lots of things that could prevent it from saving, user permissions (on the executable), server configuration, suPHP (sandboxed user), chrooted web directory, php configuration, etc. We would need to see the actual code you used to diagnose your specific issue
.
As for something to try, use this code.
<?php
if (file_put_contents('/home/project-web/my-own-project/htdocs/my-folder/test.txt', 'Hello World!')) {
echo 'File Saved Successfully!';
}
if test.txt
exists and says Hello World!
when you download and open it from SFTP, try the below.
Also most SFTP clients need to be refreshed after new content has been added to the server. So please ensure you have refreshed your SFTP client.
<?php
umask(0000); //this sets everything this script interacts with as everyone writable/executable
//(same as chmod(0777))
$output_path = '/home/project-web/my-own-project/htdocs/my-folder';
$out_file = 'fun.mp4';
$source = file_get_contents('http://data.example.com/videos/fun.mp4');
if (empty($source)) {
die('No Content Received');
}
if (!@mkdir($output_path, 0777, true) && !is_dir($output_path)){
die('Unable to create destination directory!');
}
if (file_put_contents($output_path . '/' . $out_file, $source)) {
echo 'File Saved Successfully!';
}
I tested the above on my webserver with a 5 MB
MP4 (specifically http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4
- first google result for an mp4 download) and it worked fine.
This would be a last ditch effort to get it to work.