Have been trying to solve an issue with out client updater for a couple days now. It compares the file structure on our SVN to client ftps and updates/removes where necessary. I've come to the conclusion that some files don't get updated because of a
if ($stream = fopen($path))
that all of a sudden (after many successful attempts) fails. I'm not including too much code because I doubt it would help. It all quite abstract and full of defines.
What happens is I upload a couple scripts to the server, run them and then delete them again. These scripts get called with fopen().
But for some reason after a bunch of fopen() calls to the uploaded script (before the delete, I have checked this and made sure the scripts successfully get uploaded aswell)
it all of a sudden throws this error
fopen(http://www.mysite.com/back_it_up.php) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
Anyone have any idea what might be interfering with my fopen?
Ive tried clearstatcache() and checked the rights of all the files (0755) and done quite a bit of research on this problem already.
Related
I have a VB.NET software that uploads files using an HTTP request to PHP. This worked fine until May but now it fails when uploading files over 65KB. I can not tell when it stops to work exactly. Even though, I don't think it is relevant. So to be clear, uploading a file under 65KB works correctly.
I looked with my hoster and he doesn't see any error neither do I on the server (the part I have access). VB.NET doesn't give me a pertinent error, but using WireShark, I've been able to get either a 500 or a 400 error. But it didn't give me clues on what is failing.
I verified this question which is not solved, though the things said there are OK on the server too.
PHP not uploading file over 55 kb
I have another option to fix it: splitting my files in chunks of 50KB and rejoining them via PHP. Though, I rather understand what is happening because this can happen again even with chunks of 50KB.
Server is Apache/2.4.28 (Unix)
EDIT 1
I have new conditions: I now have my own server running on Windows + Apache 2.4 + PHP 5.6.
Now it goes a little farther. I have an error when using move_uploaded_file function that gives me: Error #3: The uploaded file was only partially uploaded. It is coherent with the file being stopped to be sent near the end. So I now receive an HTTP 200 response but a failure after ward even though I suspect not being there.
I can certify I did not stop my VB.NET software that is uploading the file.
I tested changing KeepAlive to Off/False on both sides. No luck :(
Tried to add header ("Connection: close"); in my main file (that is used for all transactions with this VB.NET software). No luck.
Even though, it is not currently an issue, I changed (PHP configs) the upload_max_filesize to 256M and post_max_size to 300M (because it will be a problem if a can figure out this one).
I got those suggestions from : https://wordpress.stackexchange.com/questions/176465/failed-media-upload-the-uploaded-file-was-only-partially-uploaded
The only one I could not try is replacing an apache/php module which doesn't seem to exist on Windows.
Depending on your server's configuration, when an error 500 is returned an error_log is written. The problem is with the error 400. Which according to wikipedia's list of HTTP codes is actually a BAD REQUEST. Some output from your error_log when the attempt is being made might put us in the right direction.
I was using file_get_contents() to fetch information from an external URL. It was working perfectly on the server before. But now, somehow it fails to work on the server. (No changes in the codes.) It keeps giving me the error: failed to open stream: Connection timed out.
I have tested it on localhost and it works perfectly. I have checked allow_url_fopen option, it is still On.
So, what could be the reason(s)?
file_get_contents does not work well at all with getting remote files and should not be used. It does not deal with slow network connections or redirects, and does not return error codes. You should use curl instead to fetch remote files.
There is an example in the manual for curl_exec:
http://us3.php.net/manual/en/function.curl-exec.php
I used file_get_content() to read from the uploaded image temp file and store in database.
Everything is work fine except this warning. It show every page of my site. And there is no such page "footer.php". Is it the server problem or I need to change that function.
Warning:
file_get_contents(http://admanager.nethosting.com/getads/www.mogoke.5gbfree.com/):
failed to open stream: Connection timed out in
/usr/share/php/footer.php on line 11
The problem is another invocation of file_get_contents, which downloads advertisements from a remote server, but that download fails due to network problems or a firewall.
This looks very much like your code or server had a security vulnerability and someone uploaded code that includes ad banners on your website (but the money for the clicks of course goes to the crooks instead of you). Removing the malware (i.e. the added advertisement lines, probably heavily obfuscated) should suffice. See this security.stackexchange.com question for more details.
Well, this is a problem I have never seen before.
I am trying to stream an FTP file using PHP's fopen() and feof() in order to copy it from one server to my own. This works fine when using normal http:// URLs. However, when using the ftp:// protocol, I'm receiving the following error:
fopen(ftp://.../streaming/planted2.mp4) [0function.fopen0]: failed to open stream: FTP server reports 550 /streaming/planted2.mp4: not a plain file.
Bear in mind that I have confirmed the URL is correct.
If I pop it into my browser's search bar, it always loads correctly.
Following this error, any attempt to use feof() or fread() on the wrapper results in an error complaining that the respective function expects a resource, but that instead a boolean is being provided. This would not be the case if fopen() was not failing.
As the files are quite large (several gigabytes at times) streaming is mandatory. Also, due to the configuration of the server, I need a way to loop through each chunk in order to buffer some output. If I don't, the server holds up. It's a weird configuration on Rackspace's behalf. That's why I'm using feof().
So, without further ado, my question is this: What does the 550 error mean, and what is a "plain file"? If it is a problem with the configuration of the server I am attempting to download from, what are my options, given my limitations?
EDIT
I have determined this is a server issue. However, the problem is still unresolved.
I contacted my boss and our server administrator, and the server guy told me to test this out on a different Windows-based server instead of the Linux-based one I was playing with. My script works with the Windows server, so I have confirmed my script is not in error.
Unfortunately, my boss still wants me to figure out the problem, and find out why it's not working on the Linux box. I have absolutely no idea why, and don't know where to look. Any hints would be greatly appreciated!
I've just come across this issue when trying to get a file from a sco unix server.
Server File Location: /home/user/data/myfile.csv
I can put the below into any browser and it gets the file.
ftp://user:password#host/data/myfile.csv
However if I run the below, I get the same error as you
$f = fopen("ftp://user:password#host/data/myfile.csv", "r");
However, if I put the full path into fopen - it works fine.
$f = fopen("ftp://user:password#host/home/user/data/myfile.csv", "r");
I'm not sure if this will fix it for you, but works for me.
I am using the official Microsoft example and this example as the basis for my code to upload a file from Silverlight to a PHP script.
I am calling **HttpWebRequest.BeginGetRequestStream()**, writing the file over a file stream, and then calling **HttpWebRequest.BeginGetResponse()** to get the response. When I call HttpWebResponse.EndGetResponse() I get the following exception every single time:
{System.Security.SecurityException ---> System.Security.SecurityException: Security error.
at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
at System.Net.Browser.AsyncHelper.<>c__DisplayClass2.<BeginOnUI>b__0(Object sendState)
--- End of inner exception stack trace ---
at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at FileUpload.FileUploadProcess.GetReponseCallback(IAsyncResult AsyncResult)}
I have both clientaccesspolicy.xml and crossdomain.xml files in the base directory that allow access. I ran Fiddler and have seen it download the clientaccesspolicy.xml file so it is hitting it correctly.
The PHP file is running on Apache2 and just does a fread on php://input to read the data as the examples show. It is not receiving any data which leads me to believe that the SecurityException is forcing it to abort the write.
Has anybody seen this issue before and can point me in the right direction of a solution?
Have you checked to make sure the webserver/php application has write access to the directory you plan on storing the uploaded file to?
This could be causing it to abort prematurely.