Recently, my client website is collapsed in some certain page, not the whole website.
When open the C page (collapsed page for short) in Chrome, it will inform "The webpage is not available"
Error 330 (net::ERR_CONTENT_DECODING_FAILED)
It looks like a problem with this option in my client's PHP file:
ob_start('ob_gzhandler');
When I removed it, the C page is back to work normally but the page is no longer compressed as before.
I tried to add it back with this code in some Google source at the end of page but now whole website collapsed so I can't put this option to PHP file now:
ob_end_clean();
ob_flush();
Is there any safe way to enable compression for website now?
I tried with .htaccess but it didn't work.
The site is using IIS server with Windows Server 2008.
Related
Is it possible using the header() function or perhaps another php function to pass a file to the browser locally?
I am currently using Chrome. I have the Office Editing for Docs extension installed which essentially allows me to open Word docx files locally into my Chrome browser by passing the full directory and file name into the URL address bar of Chrome. This essentially opens the Word file in Chrome. I would like to accomplish this task in php
I have tried the following below but no luck.
header( 'Location: file://c:\users\jbloggs\desktop\test.docx' );
I know the header() function is primarily used for redirecting to a web page
header( 'Location: http://www.google.com' );
Any help much appreciated.
It doesn't work this way, because you are trying to redirect from a remote server to a local file path. Chrome doesn't accept this because of security considerations. Note that it doesn't matter whether your web server is running on the same physical machine, it is seen as a separate server from your local file system. You can however accomplish this task using normal HTML:
Document
If you save this to a static HTML file and open it in your browser you should upon click be redirected to the document. If you want a direct redirect, use JavaScripts window.location You cannot however serve the file from a HTTP Server, like mentioned above.
If you want to do so, you have to serve the .docx file from your server as well, by including it as static content and then linking to it via HTTP as well.
Hope this helps!
I have made a custom theme with wordpress locally with wamp.I use notepad++ for writing my code.Some days before when I wanted to load my page from notepad I had to go to run->launch in Firefox and had no problem showing the page where in the address bar the URL was:localhost/wordpress.
Now when I try to load my php files from notepad (run ->launch in Firefox) it shows a corrupt html page not all of it ,with some rules of php and without CSS and no images.In the address bar when running my project from notepad the URL is file:///C:/wamp/www/wordpress/wp-content/themes/revenant/page-about-us.php which is incorect ofcourse.Also it does not understand the php code.For example the title for about us page is
<?php echo get_the_title('about-us'); ?>
But when I write manually in the address bar the URL of my project like localhost/wordpress everythng shows as they shown before with no problem.I have not changed any settings in notepad.Why this problem came up with no reason?Why it doesnot load php and css? Thank you!
Notepad++ doesn't know that you have a webserver running or what the document root is, so it cannot take you to the file's URL. When it opens the file in the browser, it is loading the file directly off the hard drive (hence the file://). It is not being served by the webserver that knows how to parse PHP, it is being read directly by the browser, which does not.
On my Apache webserver i can server PDF files directly in the Browser with a simple Anchor link like:
Click to display PDF
This Works fine.
Now, i've got a lot of PDF's i want to Protect. So i moved them all outside the Web folder, and are serving them through a PHP download program - i called it download.php
To be sure that the pdf files are not downloaded as "download.php" i have to set the Content-Disposition Header to 'inline;filename="mysample.pdf"'. Inline because i want to open it in the Browser.
No Problem, all works fine. the files are downloading fine on Windows and Apple Browsers and are displayed IN the Browser, just like when its served directly from the Apache Server.
But my download.php doesn't work with Android Browsers... It's always just downloaded but not opened in the browser. You have to find the file in your messages and open it separately. When served directly from Apache it IS opened in the Browser.
It seems to be connected with Content-Disposition Header im setting in my download.php, because this is the only difference i see in the headers when download direct and indirect.
Anybody had the same problem?
Thanks
Per
I have create a CSV file in my php code,
after create CSV, I try to open the CSV using window.open(),
this will work fine all browser except IE 7 and IE 8,
in IE a new window open then it close automatically
how to solve this problem,
If I recall, Internet Explorer has a peculiar quirk when trying to open files, even if the proper MIME type is set in the header.
You may need to do the following to get the CSV to download:
Go to Tools > Internet Options
Select the Security tab, then press the Custom Level... button
Scroll down to the Downloads section, and under Automatic prompting for file downloads select Enable
Hopefully, that should resolve the issue.
Try adding the following at the beginning of your script:
header('Content-Disposition:inline');
This should direct the browser to display the file instead of prompting a download, which may be the problem.
I have a weird unexplainable phenomenon going on.
I downloaded some source code from a website, a basic PHP script. It came with an SQL to reference numbers as part of the script.
I uploaded the file called post.php and SQL file to my server and ran it - but - instead of executing the code in the PHP file, it loads the content of the webpage of the author of the source code. and stays on my server URL.
The code in the file has nothing to do with the author's site, or graphics or links or redirects or anything.
EVEN IF I delete the entire contents of the post.php file, run the empty file and it STILL LOADS CONTENT from the author's website, where I downloaded it from.
Refreshed browser, restarted, reloaded, you name it. How is this physically possible?
-----UPDATE
In addition when I try renaming PHP files on my server, they become permanently broken "oops broken link" error.
It would be very helpful if you could post some more specific details about what the script was, etc. But, here is my guess. Firstly, make sure that your web server is not doing any caching. If the problem persists, try getting rid of the post.php file itself. Then, I would check to see if the PHP script has created any HTML/PHP files on its own. If all else fails, try going into the code that you downloaded and see what its doing.