i doing excell file reader in my local is working fine, i giving the base url like this
"C:/xampp/htdocs/school/uploads/staff_importFiles/".$sFileName
So my local is working fine,but when ever i uopload the code in my server it is not working , in my server base url i am ging like this
"http://domain.in/school/uploads/staff_importFiles/".$sFileName
If i am giving means i am getting error like this
The file http://domain.in/school/uploads/staff_importFiles/30e97727b3dc9f2ebe493fa3165b51c7.xls was not found
inside this staff_importFiles folder my files is there , but don't know it throwing the error, i am using codeigniter,any one help me please
In codeigniter use base_url() function.
<?php echo base_url().'uploads/stuff_importFiles/'.$sfileName ;?>
I think you have subdirectory named school in your local. While it does not exist on your server. So you should change your server url to.
"http://domain.in/uploads/staff_importFiles/".$sFileName
While this is not recommended way of doing this. You should use base_url()
Related
My copy code doesnt work for some reason. Tried several things.
this is the code that I am trying to use
$fb_foto_url = $userData['picture']['data']['url'];
$plaats = '/assets/images/profielfotos/fiel.jpg';
copy($fb_foto_url, $plaats);
The $userData['picture']['data']['url']is getting filled with this for example: https://lookaside.facebook.com/platform/profilepic/?asid=113831052838678&height=200&width=200&ext=1527931138&hash=AeSlklMNX6l4Uanh
I need that to get stored in on the server. But it isn't working for some reason. I am doing something wrong but can't figure out what.
If someone can help me with this code, would be nice.
Try this:
file_put_contents($plaats,file_get_contents($fb_foto_url));
PHPs copy function expects path's, not URL's.
A (server-) path is a directory name on the machine the PHP code is executed on.
An URL is a virtual name that may or may not point to such a physical path or is resolved dynamically.
Example:
The server path to a websites images might be /var/www/example.org/assets/images/, while the URL is http://example.org/assets/images/.
http://php.net/manual/en/function.copy.php
I tried the following coding for a 'UIWebView:
let kapitel3 = "<html><head><title>Chapter 1</title></head><body><h1>This is a title!</h1></body></html>"
This HTML code works fine and "UIWebView" shows this code. But if I try to insert a PHP code within the HTML code like this:
let kapitel3 = "<html><head><title>Chapter 1</title></head><body><h1>This is a title!</h1><?php print \"Hello world!\";?></body></html>"
Then the PHP code won't be showed. Why doesn't 'UIWebView' translate this PHP code <?php print \"Hello world!\";?>?
Is it not possible to integrate PHP code in a String like above?
Thanks for any hints!
UIWebView is only a simple web-browser...
You can't use php like that if you don't have a local webserver with a php interpreter installed!
You could load a php page from a remote url but your phone must have an active internet connection...
Possible local solution:
You can't use php locally, but in a UIWebView you can still use javascript!
I don't know what you are trying to do...but if you need your app to work offline (with local files) using php is the wrong approach.
I am trying to display the PHP source of a file inside a page. I am using show_source function in this way:
<?php
$nomefile = $_REQUEST['nome'];
show_source($nomefile);
?>
When I try this code on my local PC (using USBWebserver v8.6), it works smoothly, displaying the PHP code of the page. But when I try it on my remote webserver (Altervista), I only get an empty page.
I even try to substitute variable $nomefile with name "visite.php", which is the name of a file residing in the same folder, but still I get no result? I try with echo show_source(...), but no result again.
Is there an error in my code? Or maybe show_source is not compatible with all version of PHP? Is there any easy alternative?
Thanks a lot
Giancarlo Perlo - Italy
http://angulairapi.rohanchhabra.in/airports
This is a very simple route I have created in Laravel. It just takes a json file in the public directory, decodes it into an array and return the same json in response.
If you go the route (mentioned above), the error say "No such file or directory" but it exists in fact. It is working fine on my local machine. But when I pushed the same thing on my server, it is giving me this error.
http://gitlab.learningtechasia.com:8901/rohan0793/angulairapi.git
I have made the repository public so that everyone can have a look.
I have tested on my machine asset() is working for me and the path(public/airports.json) you have written reflect same error for me.
Laravel`s Helper function asset("file_name") generate a URL for an asset.
please check laravel`s helper function documentation for more detail
put this code in your routes.php and try again
<?php
Route::get('/airports', function(){
$airports = json_decode(file_get_contents(asset("airports.json")));
return Response::json($airports);
});
Route::get('/flights', function(){
$airports = json_decode(file_get_contents(asset("flights.json")));
return Response::json($airports);
});
EDIT
When you are working on local machine your url having word public i.e localhost/project-name/public/airports.json.
but when you deploy project on server it seems it remove public word from url, so what happing here, server finding airports.json at location http://angulairapi.rohanchhabra.in/public/airports.json but its not actually there its at location http://angulairapi.rohanchhabra.in/airports.json, so it is recommended to use laravel function(in this case asset()) to generate url/assets link.
An alternative to asset() and Anands answer is the helper function public_path(). It returns an absolute file path from the system point of view and not a URL.
$airports = json_decode(file_get_contents(public_path().DIRECTORY_SEPARATOR."airports.json")));
asset() should be used for URLs to files. URLs that you send to the client. You should work with public_path() for internal things, such as getting the content of a file.
I'm using CakePHP 2.0.4, PHP 5.3.1, Apache 2.2.14.
For example: the filename is F#7m7~1.gif. It really exists, the path and filename are correct.
Before print HTML tag, I encode it by using urlencode() and the tag goes like:
<img src="/chord/img/chords/F%2523m7~1.gif" alt="F#m7">
But the image is not loading. ('Chord' is a CakePHP Plugin)
I also tried to load it directly on the browser, http://myapp.localhost/chord/img/chords/F%2523m7~1.gif but what I get is: "Missing Controller Error: Chord.ImgController could not be found."
Everything works fine with the file as A~1.gif, but it brokes with filenames such as F#m~1.gif, B(7)~1.gif etc.
Everthing was working ok in pure PHP coded version. Now, it's not working at CakePHP.
Is there anybody have a clue?
You seem to be double-encoding it, the right urlencode for F#7m7~1.gif is F%237m7~1.gif, not F%2523m7~1.gif. Just remove one of them.
The Missing Controller error is just because there is no such file on your server, so Cake thinks you're trying to call an ImgController, within the Chord plugin. Try http://myapp.localhost/chord/img/chords/F%237m7~1.gif, it should work.
Anyway, as #GordonM pointed out, it's best to stick with normal characters for filenames.