Might be somehow copy of this thread but the choosen answer is not giving me a resolution.
I have copied site built on codeigniter to localhost from server and I get this error message. I have checked the case (altough Windows is non-case-sensitive) in the files and I am using MY_Controller as classname, filename and including file as well, made screenshots, see images:
1. Extending MY_Controller
File structure
MY_Controller class header
The file is in the core folder, but I still get this error message.
What am I doing wrong and what could be the solution?
In the index.php file in the root folder of the site check that the $system_path and $application_folder variables are correct. For example, I keep mine outside of the publicly accessible path, at the same folder depth as my public_html and so these for me are set as:
$system_path = '../system';
$application_folder = '../application';
If you've copied it from a web server then it's possible that something similar has been setup or perhaps an absolute path has been specified.
Related
Form inside an ApiController. I need to read content of a file embedded inside the project. But I can't resolve the correct path
[HttpPost]
public HttpResponseMessage DoSomething()
{
String content = System.IO.File.ReadAllText(#"~\SomeFolder\file.txt");
}
Doing like this the resolved path point to:
C:...\bin\Debug\~\SomeFolder\file.txt
instead of
C:...\SomeFolder\file.txt
Does anyone have any idea how to solve this under OWIN Self Host?
In general, it does not make sense to try to access a file inside a project. All the files necessary for deployment (dlls, assets, txts,...) should be copied to a separated folder so that when we need to deploy, we just need to copy that folder.
You should set the file as Copy To Output and try:
String content = System.IO.File.ReadAllText(#"SomeFolder\file.txt");
which is resolved to
C:...\bin\Debug\SomeFolder\file.txt
To make the code work with OWIN, you could take a look at this answer How do you resolve a virtual path to a file under an OWIN host?. It suggests using HostingEnvironment.MapPath and falling back to manipulating file paths manually in self host scenario.
When using Dojo file caching with Worklight receiving a 404 Error when running in Simulator. It appears the file being loaded is not being copied from the common area to the device. Is there something else I need to define in my project to make that happen? There must be a convention and I wanted to follow it going forward as I expect to have more template files in the project.
My define statement in a .js file:
define(["dojo/_base/lang", "dijit/layout/ContentPane", "dojo/dom", "dojo/text!./templates/Order.html"], function(lang, ContentPane, dom, template){
...
var cp1 = new ContentPane({
title:"Order",
content: lang.replace(template, someJson)
}).placeAt("temp");
My folder structure:
In the common/js directory I have the above code in a .js file and I have a templates folder to keep the Order.html and I would expect to have other template files stored there in the future.
Error on the console:
GET http://localhost:10080/DojoProject/apps/services/preview/DojoApp/windowsphone8/1.0/default/layers/templates/Order.html 404 (Not Found)
It seems that the way you are specifying the path, browser tries to find the file in the "layers" folder which is sibling to "templates".
Have you tried to modify the "dojo/text!./templates/Order.html" to something like: "dojo/text!./../templates/Order.html" to navigate one level up, then go into the templates folder?
I'm not sure this will work, but I think it worths a try.
I'm using GroceryCRUD to act as a front end for a database containing news releases. Secretaries can go in and add/edit/delete news releases in the database easily now. Only qualified users are able to access the application root via an .htaccess password. The problem with this is that GroceryCRUD uploads assets such as photos are uploaded to the directory /www/approot/assets/uploads/ which is password protected since /approot/ is protected.
My ideal solution would be to set an upload directory outside of the application root which is where I'm running into trouble. By default this is how GroceryCRUD handles uploads:
$this->grocery_crud->set_field_upload('photo1','assets/uploads/');
I've tried changing it to something like this:
$this->grocery_crud->set_field_upload('photo1','/public/assets/uploads/');
I was hoping this / would make the path start from the document root instead of the application root, but it throws this error:
PHP Fatal error: Uncaught exception 'Exception' with message 'It
seems that the folder "/Users/myusername/www/approot//public/assets/uploads/"
for the field name "photo1" doesn't exists.
This seems to suggest that CI or GroceryCRUD just takes the second argument in set_upload field and just concatenates it onto the end of the site URL that is defined. Is there any way around this that doesn't involve creating a user login system?
Try using relative path.
$this->grocery_crud->set_field_upload('photo1','../assets/uploads/');
.. -> Go up one directory
I ended up implementing a login system outlined in this tutorial:
http://net.tutsplus.com/tutorials/php/easy-authentication-with-codeigniter/
It was quite simple to set up and suits my needs. I found ways to give access to the directory using httpd.conf directives but I feel like this was a more viable solution since I don't have direct access to server configuration files.
Maybe in the future GroceryCRUD will allow placement of uploads outside the application folder.
I have public folder in root of my project. Placed a couple of images, when I try to access them, it says "Sinatra doesn't know this ditty..."
Isn't default public folder supposed to be called "public"? Or do I have to explicitly set that?
Need to not include /public in path.
The folder name should be "public" and then access it with /image.png when your folder structure is public/image.png
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
error using include_once with a php variable
My code is like this:
<?php // file location: include/config.php
$CONFIG["DIRECTORY"]["HTMLINC"] = "http://127.0.0.1/mysite/html_include";
?>
,
<?php // file location: ./template.php
require_once("include/config.php");
// ...
require($CONFIG["DIRECTORY"]["HTMLINC"] . "/anotherpage.php"); // Doesn't work
?>
It gives the following warning message:
Warning: require(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in...
I'm currently testing the code in my local server, so I can easily change the value of allow_url_include. But I will eventually upload this code to a remote server. I cannot guaranty that allow_url_include will always be set to 1.
How do I prevent this warning message and make this code work?
that isn't an absolute path. that is a URL. the absolute path would be the path to the file on disk. If you go to /var/www/mysite/html_include to access the file to edit it, that is the absolute path. You would want to set $CONFIG["DIRECTORY"]["HTMLINC"] to that absolute path. You can use $_SERVER['DOCUMENT_ROOT'] to get the web root supplied by apache and append the /mysite/html_include to generate the right path. ideally you would probably have a separate config variable called something like APP_ROOT that is the document root + /mysite (the absolute path to your application). something like:
<?php
$CONFIG["DIRECTORY"]["APP_ROOT"] = $_SERVER['DOCUMENT_ROOT'].'/mysite';
$CONFIG["DIRECTORY"]["HTMLINC"] = $CONFIG["DIRECTORY"]["APP_ROOT"].'/html_include';
This would allow you to use APP_ROOT for other variables too:
$CONFIG["DIRECTORY"]["UPLOADS"] = $CONFIG["DIRECTORY"]["APP_ROOT"].'/uploads';
$CONFIG["DIRECTORY"]["IMAGES"] = $CONFIG["DIRECTORY"]["APP_ROOT"].'/images';
$CONFIG["DIRECTORY"]["THUMBNAILS"] = $CONFIG["DIRECTORY"]["APP_ROOT"].'/thumbs';
etc.
Don't use http URLs as your includes - they won't work the way you expect anyway.
If they are enabled, they will be treated as external URLs, and thus parsed by PHP before being served to the including page. The resulting output will therefore not include any PHP code because it will already have been executed.
If you want to include a local file, you need to provide a directory path on the local disk, not a URL (not even a localhost URL).
In any case, the ability to run includes from a URL is virtually always disabled by any sane hosting company because it is a massive security risk to allow code to come in from a third party site and be run directly on your system.
If you want to include a file local to the web site, you can use $_SERVER['DOCUMENT_ROOT'] to reference the root of the site, or __DIR__ to reference the directory of the current file. I guess the former would be best in your case, so you need this:
$CONFIG["DIRECTORY"]["HTMLINC"] = $_SERVER['DOCUMENT_ROOT']."/mysite/html_include";
hope that helps.
You put in a URL by using "http://127.0.0.1". You must reference it from the file system, not by local IP. So you need to set $CONFIG["DIRECTORY"]["HTMLINC"] = '/path/from/root/html_include'
"Absolute paths" in file systems are not like absolute paths in HTML (which begin with the protocol - i.e 'http://').