I feel pretty stupid asking this... but I have a small php script that generates a image based on some GETs and output's it to the browser.
It works fine on my server, but I moved it over to the client's server and I get a 404 error instead of the image. Problem is I have no ideea how to see what is wrong.
Normaly I get an error in the browser so I know what is going on... but not beacase the output is an image I get nothing.
LE: I tried this, at the begining of the script:
error_reporting(E_ALL);
ini_set('display_errors', true);
but nothing.
If you get a 404, the PHP script is either not found or redirects to another resource (a generated and cached image file?) but the path to it is wrong (or the image file can't be generated because of right issues?).
As suggested, remove the header() if any (it's also probaly using a header if the script redirects to the real file after generation).
If the script is delivering the image directly without any redirect, then enabling errors won't help on a not found URL ;-)
Related
Hi I have the following problem. I use jQuery file upload plugin and want to implement file uploader in one of my website pages. I am using the UI version so the thing is working, the files are uploaded but when i try to delete them i have an 404 error on the request. I am using POST request. The problem is that I get 404 header error and that is screwing the code. My page is responding with the right JSON data but the header is 404 I searched the whole [uploader class][3], but i can't find where the header is set and even if I comment that 404 line
if (!$this->is_valid_file_object($file_name)) {
return $this->header('HTTP/1.1 404 Not Found');
}
Nothing happens so I cant understand where in which javascript file or in the upload handler class the headers go wrong and how to fix the problem.
So my ajax return is like follows:
_method:DELETE
/my_domaing/some_page/uploadAction/file:action_test_file_3%20%281%29.doc
POST 404 Not Found text/plain jquery.js:8706 Script 991 B 360 B 20 ms 20 ms
I think the problems comes from my framework cause in plain php I can upload and delete files. But when i open the page in my browser with that link I can see the JSON response which is:
{"file":{"name":"action_test_file_3.doc", "size":61440,
"url":"http:\/\/my_domain\/files\/action_test_file_3.doc",
"deleteUrl":"http:\/\/my_domain\/some_page\/uploadAction\/file:action_test_file_3.doc\/
_method:DELETE\/file:action_test_file_3.doc\/_method:DELETE","deleteType":"POST"}}
I don't know what I need to get so the file be deleted, but I know that the header information is gone wrong cause I can open it and see the information but the POST request sees the 404 error and just doesn't do nothing.
The framework I use have a .htaccess rewrite rule which is the following:
RewriteEngine On
RewriteRule !\.(js|ico|gif|jpg|png|css|swf|htc|txt|doc|docx|xls|xlsx|pdf|htm|html|
bmp|flv|xml|zip|plist|ipa|woff|ttf|svg|eot)|^design(.*)|^sks(.*)$ index.php
But I don't think the rule has anything to do with this upload. My framwork uses Smarty. I really can't find the way to solve the problem the uploading is working perfectly so why not the deleting. And I have write/delete permissions on the directory.
I don't get any javascript errors and in my php log there are not errors regarding this page.
So I think the problem is with the header information and if it returns 404 the file is just not deleted that is all. But I can't understand where and how this is happening.
So feel free to ask me anything but I can't send you a live demo cause it is a developer server, but I will do anything to try and resolve this problem cause I am struggling with it for almost 2 days. Any help is and will be appreciated!
I went to edit this PHP file - it's supposed to generate those captcha security images on contact forms - the images werent working, so I was going to see if there was a broken path or something i could fix simply.
But when I opened the file it looked like this:
http://mydomainsample.com/explosion/screenshots/Screen%20Shot%202012-05-17%20at%209.34.14%20AM.png
complete gibberish.
Is it possible this happened somehow while downloading the file from the server? I did not have ftp access to the site originally - we got control of the domain and transferred it from one host to another.
I used site sucker to backup the site before transferring, but it downloads php files as html files. you end up with filename.php.html.
in the past this has never turned the php into incomprehensible gibberish, so i dont understand why it did now.
The problem is, you cannot use programs like "site sucker" to get PHP files. This is because when you get a PHP file from a URL, the file is executed, and you're getting the output of the script. That's why you get .php.html.
It doesn't "turn the php into incomprehensible gibberish", the server runs the script and you're getting the output. Most of the time the output is HTML, which you can open as text. In this case, the script's output is a PNG file, thus why you see "gibberish". Rename the file to .png, then you'll see the image.
You need to get FTP access in order to get the PHP source.
That's a PNG image, not PHP source code.
The file actually looks like a PNG image, maybe you just downloaded output the PHP script has generated?
I have a wiki api site:
http://en.wikipedia.org/w/api.php
when I save the api.php, I can't see any post or get method behind that.... but I try to write a simple php program.... like this
test.php:
<?php echo("testing"); ?>
when I updated to server, and save the test.php, people can see my source code. but after I downloaded the api.php, I don't see any php source code from the api.php, but I can pass parameter to the api.php, how can they do so? Thank you.
Because when you hit that Wikipedia api.php page, you get an HTML document. You're not downloading any Wikipedia source code. You're downloading the output of a PHP script running on a Wikipedia server, and that output happens to be HTML.
As for your test file, since you get the source code instead of "testing", that means your server isn't properly configured and isn't seeing a .php file as a PHP script, and is instead serving up its raw contents.
If you uploaded a file to your server that contained php, and when you view source in your browser you see that php code, that means that your server is not executing your php. It would be parsed out naturally if it was.
You cannot see the source code of a php file, because when it is accessed on the server it is first interpreted by PHP on the server-side.
When a request goes for api.php, the server (most probably Apache) using it's PHP handler, will execute the PHP code and return you the html. Therefore, you will only see the HTML, not the PHP source code.
The reason you are able to view source code of test.php could be because your server doesn't know how to execute PHP code coz it may not be having a PHP handler. Therefore, it is showing the source code.
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.
No matter what I change in this script, when I go to upload the file, the page is looking for the action do-nothing.htm. This is what the ACTION of the plugin is set to in the downloaded example, but I have changed it.
I have also changed some lines in the Javascript to see if I could get something working, but nothing. In fact I can't seem to find any reference to do-nothing.htm yet the console still gives me a 404 error do-nothing.htm not found. Any ideas?
the example works.