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.
Related
I have a vBulletin 3.8 forum.
When we click Edit button of any post (so the Quick Edit form should displayed), I get this error on the browser's console:
XML Parsing Error: xml processing instruction not at start of external entity
Location: http://www.xxxxx.xx/ajax.php?do=quickedit&p=438
Row number 2, Column 1:
... the Quick Edit form is not appearing the the progress bar displayed permanently.
I have try to disable hooks/ plugins, but the problem still appears.
I have this row on config.php: ini_set("display_errors", false); so I don't think it is a fatal error/ warning by PHP which brokes the xml normal syntax.
I have informed that this appear starts after the move of the site to another server. Does it say something to you?
Any general idea about this error?
EDIT:
Well, I found the reason of this issue, but I don't know how to fix it. Exact the same site on a localhost testing board works perfectly, but on the live server ANY html page/ ajax call etc, has a useless empty line as line #1.
For normal html pages, there is no reason for the browser to return an error, but when we're talking about an ajax call, this empty line at the top of the response, breaks the xml parsing from the browser. So it seems it is a server/ PHP/ Apache setting that applies this empty line. Any idea how to fix it? https://imgur.com/a/4neb0
It might be late for you but any new comers with php/nginx/apache can get an understanding of why.
Answer is simple: When moving the code, you might not be using git/rsync/scp but let me guess, you used zip (and probably Windows/Linux involved).
How to discover it was a two-day journey with many things tried:
We have the same error, we were also moving our servers. We tried:
We thought the server software version was a problem.
We thought the cloud provider OS image was a problem.
We used docker to avoid these problems, but the empty line problem persists.
We thought the code ?> ending was a problem, I went through all of them. But it wasn't.
I finally asked my colleague: How did you get the code? From Git? He said he downloaded from ZIP and then uploaded to server.
I removed code on the server (which extracted from a zip) and used git to download a fresh copy from our github.
Magic, problem solved. The empty line gone.
So I think the problem is with the zipping progress might have changed some file empty lines. Always use git.
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'm currently using the php client for docusign (https://github.com/docusign/docusign-php-client) and everytime I call DocuSign\eSign\Api\EnvelopesApi::getDocument I get a message like
[INFO] Written ##### byte to /tmp/######. Please move the file to a proper folder or delete the temp file after processing.
This is apparently triggered by this line (https://github.com/docusign/docusign-php-client/blob/master/src/ObjectSerializer.php#L260)
error_log("[INFO] Written $byte_written byte to $filename. Please move the file to a proper folder or delete the temp file after processing.\n", 3, Configuration::getDefaultConfiguration()->getDebugFile());
I tried pretty much everything I could think of, using #, setting error_reporting to 0, setting the debugfile to php://stderr, to /dev/null, all to no avail.
I'm using this method in the context of a custom Symfony command if that's of any use.
The SDK is outputting that text as an informational message to the system log. I understand your desire to not see it. I have filed an issue against the SDK about this.
In the meantime, I suggest that you git fork the SDK and comment out that line.
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.
I am trying to serve a json data file using content from a database to be used by a dojo widget (dijit.form.FilteringSelect). All the parts seem to be working, but when it's all wired up the ajax call for data returns a 500 error.
In php, I am serving the file using
header('Content-Type: application/json');
Accessing the URL using a browser (Chromium or Iceweasel) initiates a download of the file. The data looks fine. If I save the file back to the server and serve it as a static json file it works just fine.
However if I connect the widget to the data file that is processed by PHP and watch the network connections using Firebug or the Chromium dev tools, the data call returns a 500 error from apache. Looking at the apache log files there is no mention of a php issue, just a one liner showing the request was returned 500.
This happens whether I use a .php file extention or add a special handler for the .json file to be processed by PHP. Again, calling the URL directly returns 200 and the correct data.
What do I need to change in either my PHP code or the apache server so that it will successfully send data requested by dojo?
The development server being used here had the PHP auto_prepend_file value set to include some libraries that included a page templating engine. While this was not causing any issues when the page was called normally (and no templating was being done since the functions were not being called), an error in the included code was causing a bad library to be loaded if the X-Requsted-With GET request header was set to XMLHttpRequest, hence the 500 error only when called from the AJAX call. Additionally the library was trapping the errors it generated which is why the php errors weren't showing up anywhere.
Otherwise the header shown in the question is correct.
application/json is a valid header preferred by all common browsers, you may have some error in your json, try checking your json data in http://jsonviewer.stack.hu/ maybe that helps