I am trying to implement blueimp to my codeigniter project for multiple image upload of images. i am facing 500 (internal server error) i know this appears if we have any error in our php script.
in my php script i am getting response as {"files":[]} to represent no of img's which are present in my img_upload folder. it have to return null object thats true but
in my console i am getting a error as the below image.
as i clicked on anonymous function Here in my.js redirecting me to below function.
$.ajax({
// Uncomment the following to send cross-domain cookies:
//xhrFields: {withCredentials: true},
url: $('#fileupload').fileupload('option', 'url'),
dataType: 'json',
context: $('#fileupload')[0]
}).always(function () {
$(this).removeClass('fileupload-processing');
}).done(function (result) {
$(this).fileupload('option', 'done')
.call(this, $.Event('done'), {result: result});
});
what i am thinking is this might be issue with return type html or json but not able to to get how to fix this issue. how can i solve this issue so i can upload image without getting internal error. Thanks in advance.
I am following the following github wiki and my code is same to same.
This blog
may be its php.ini problem
Open your php.ini file
search for extension=php_fileinfo.dll
if you are using xampp it may be commented by default
change
;extension=php_fileinfo.dll
to
extension=php_fileinfo.dll
and restart your xampp...
this was solve my problem
Related
I'm using xampp on my Windows 10 dev machine and when I launch my javascript app using chrome, the browser uses localhost:8080 as the root directory.
For my php ajax calls, I have to use the fully qualified path to get them to work. For example:
$.ajax({
type: "GET",
dataType: "json",
url: "http://localhost/get_user.php",
data: {email: $("#email").val()}
});
Note that I have to use localhost for the ajax calls whereas the javascript root is localhost:8080. My php files are stored locally in c:/xampp/htdocs.
I want to use a short form url that works on both my local dev machine and on the production website. Something like
$.ajax({
type: "GET",
dataType: "json",
url: "/get_user.php",
data: {email: $("#email").val()}
});
My understanding (and I'm new to this) is that if I use the short form url /get_user.php the system uses the same root as the client side app (i.e. http://localhost:8080/get_user.php). But only fully qualified http://localhost/get_user.php is working for my ajax calls.
I get the following error message when using the short form /get_user.php:
GET
http://localhost:8080/check_login.php?password=xxxxxxxxxx&email=drew%40aol.com
404 (Not Found)
So the client side uses localhost:8080 and the server side expects localhost. I'm sure this is probably an xampp config issue but haven't been able to solve on my own. Any insight would be appreciated.
Try changing your data type to jsonp rather than json. I think you are running into a cross-origin resource sharing problem. A permission problem, essentially. localhost and localhost:8080 are two different domains, as far as your browser is concerned. If your code is executed from localhost:8080 and you give it a relative url, like /something.php, it assumes you are requesting it from the same domain. localhost is equivalent to localhost:80.
I have a site which is using Basic Authentication, visitor can login with predefined credentials. I can reach the $_SERVER["PHP_AUTH_USER"] variable, so everything works fine here.
But when I'm trying to post data with jQuery AJAX in the same domain, I can't reach the $_SERVER["PHP_AUTH_USER"] variable (not set in the $_SERVER).
Environment:
Server version: Apache/2.4.7 (Ubuntu)
PHP Version: 5.5.9-1
Ubuntu: 4.9
(Server API: Apache 2.0 Handler, so not CGI)
Chromium: 41.0.2272.76
Ubuntu 14.04 (64-bit)
Can anyone help with this problem?
Along with greet, commented that the server will accept your application if you send in the request authentication, therefore you within Jquery Ajax method, and define Dentrol method the Autentification property through getAllResponseHeaders () function, an important point is in basic mode of authentication uses javascript base 64 (btoa) to encrypt the username and pass, I hope you find it useful and invite you to visit my github, enter link description here, have some useful ools Built to to validate data when luck
$.ajax({
url : 'test_2.php',
type : 'GET',
beforeSend: function (xhr) {
xhr.setRequestHeader('Authorization', 'Basic ZWxlbWVudG86ZWxlbWVudG8=');
},
data: {},
success: function (e) {
console.log(e)
},
error: function (e) {
console.log(e)
},
});
I've got a very basic one today! I'm trying to post from jQuery to a PHP file hosted on localhost.
My JS:
$("#searchNameButton").click(function() {
var name = $("#searchNameText").val();
$.ajax({
type: 'POST',
url: 'localhost:8080/getNameInfo.php', // -> this works fine from the browser
// data: { name: name }, -> commented out
success: function(){
alert('request successful');
},
error: function(xhr, textStatus, errorThrown){
alert('request failed');
}
})
});
My PHP file (getNameInfo.php), a very basic one for testing:
<?php
echo 'TEST';
?>
In jQuery, it will always bring me to error, saying 'Internal Server Error'.
I am using Ripple Emulator and this is what appears in the console:
POST https://rippleapi.herokuapp.com/xhr_proxy?tinyhippos_apikey=ABC&tinyhippos_rurl=localhost%3A8080/getNameInfo.php
500 (Internal Server Error)
I assume it has to do more with this than with what's written in the files. Any advice? Thanks!
EDIT: Found this: LINK but it won't fix my issue. If I do what it says here, I won't get any error thrown ("" instead) but will still fail.
EDIT 2: If I set Cross-Domain Proxy to Local in Ripple (that's suggested in the link above) I get
OPTIONS http://localhost:4400/ripple/xhr_proxy?tinyhippos_apikey=ABC&tinyhippos_rurl=http%3A//localhost%3A8080/getNameInfo.php net::ERR_CONNECTION_REFUSED
EDIT 3: Changed my URL to local
C://Mobile//Cross-Platform//TestApp//www//php//getNameInfo.php
and it's working now. Have no idea how to make it work on localhost. BUt will go with this now, as it's only a learning app.
Add a header access control at top of getNameInfo.php file :
header('Access-Control-Allow-Origin: *');
So, finally I found a solution.
Even though it's not a recommended one, running Chrome with
--disable-web-security
will allow me to call a PHP script hosted on localhost:8080 from localhost:3000 where PhoneGap / Ripple Emulator stays.
I am building an Angular App with Gulp locally on my dev machine, that will eventually be a SaaS. All the data is hardcoded JSON in a service purely to get the front-end working.
Now I am ready to connect to a local database and will use PHP/MySQL.
I have a local development environment on OSX setup with Homebrew that has PHP and MySQL ready to go.
The issue:
I get a 404 when I use the url: 'db-insert.php' line no matter where I put the db-insert.php file in my directory structure.
POST http://localhost:3000/db-insert.php 404 (Not Found)
var request = $http({
method: 'post',
url: 'db-insert.php',
data: {
name: $scope.name,
email: $scope.email,
message: $scope.message
},
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
});
I have investigated
• CORS: Tried open -a 'Google Chrome' --args -allow-file-access-from-files
• gulp-connect-php
• gulp-webapp-running-browsersync-and-php
• BrowserSync Proxies
The app uses Gulps BrowserSync which has a proxy option that leverages Express to connect to a defined middleware, but I am stumped at where to point it or if it is the correct option at all.
Any explanation of what the correct way to do this is would be great. I think the answer is probably a combination of what I have found, but the implementation is the issue. Thanks much.
Ok, This turned out to be a filesystem/CORS issue. Here is how I solved it:
1) Go through the server to get to the php file
http://127.0.0.1/dev/db-insert.php
NOT
file://myproject/dev/db-insert.php
I was trying to access the file directly in the file system and not by its URL on the PHP server I have running as my localhost. When I changed the url to go through the apache server to find the file, it was able find it.
2) Once I got to the file I got the CORS issue
Adding the code below to the top of db-insert.php executes allowed the file to be accessed.The server could then execute the code.
header('Access-Control-Allow-Origin: '. $_SERVER['HTTP_ORIGIN'] );
header('Access-Control-Allow-Credentials: true' );
header('Access-Control-Request-Method: *');
header('Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS');
header('Access-Control-Allow-Headers: *,x-requested-with,Content-Type');
header('X-Frame-Options: DENY');
I have java classes that I call from my html file using this ajax code:
$.ajax({
type: "POST",
url:"http://www.verifiedalerts.appspot.com/verifiedalert?action=addIntrusionRules",
dataType:"text",
async:false,
data: "params=" + objStr,
success: function(data){
//alert(data);
}
});
when I see the log I get this error:
Uncaught exception from servlet java.security.AccessControlException: access denied
but when I run another similar file from a different computer it works somehow and now it is not working.
Does someone know how to get past this?
The error is occurring on the server, so we really need to see the App Engine code and the complete stacktrace of the exception to tell you anything useful. One thing that's immediately noticeable is that you're referring to "www.verifiedalerts.appspot.com" when you should probably be referring to "verifiedalerts.appspot.com" - the former may or may not work depending on your configuration.
I think it has to do with same origin policy:
The same origin policy prevents a
document or script loaded from one
origin from getting or setting
properties of a document from another
origin. This policy dates all the way
back to Netscape Navigator 2.0.
You might find these threads useful to workaround that:
Ways to circumvent the same-origin policy
Why same origin policy for XMLHttpRequest