Recently, I had a problem as:
Warning:include(C:\xampp\htdocs\crackverbal\application\views\errors\html\error_php.php): failed to open stream: No such file or directory in C:\xampp\htdocs\crackverbal\system\core\Exceptions.php on line 269
Warning: include(): Failed opening 'C:\xampp\htdocs\crackverbal\application\views\errors\html\error_php.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\crackverbal\system\core\Exceptions.php on line 269
Warning: include(C:\xampp\htdocs\crackverbal\application\views\errors\html\error_php.php): failed to open stream: No such file or directory in C:\xampp\htdocs\crackverbal\system\core\Exceptions.php on line 269
Warning: include(): Failed opening 'C:\xampp\htdocs\crackverbal\application\views\errors\html\error_php.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\crackverbal\system\core\Exceptions.php on line 269
I used Xampp and codeigniter-3.
I am guessing that
Under application\view\errors\html\ Folder, error_php.php file does not exist Or
Under application\view\ Folder, errors folder does not exist at all.
You can create dummy file and see if there is any error.
Under application/view/, create folder name errors,
then in errors folder, create folder name html
then in html folder, create php file name error_php.php
In error_php.php,
<?php echo "Sample text."; ?>
Just copy error folders in your codeigniter application to codeigniter view folder.
It will correct error page path. And the warnings will removed.
copy "errors" folder from "codeigniter3/application/views" and paste it into your project ("my_project/application/views").
Paste the below code into index.php
$view_folder = '';
// The path to the "views" folder
if ( ! is_dir($view_folder))
{
if ( ! empty($view_folder) && is_dir(APPPATH.$view_folder.DIRECTORY_SEPARATOR))
{
$view_folder = APPPATH.$view_folder;
}
elseif ( ! is_dir(APPPATH.'views'.DIRECTORY_SEPARATOR))
{
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
echo 'Your view folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF;
exit(3); // EXIT_CONFIG
}
else
{
$view_folder = APPPATH.'views';
}
}
if (($_temp = realpath($view_folder)) !== FALSE)
{
$view_folder = $_temp.DIRECTORY_SEPARATOR;
}
else
{
$view_folder = rtrim($view_folder, '/\\').DIRECTORY_SEPARATOR;
}
define('VIEWPATH', $view_folder);
You should download a fresh codeigniter folder and copy the error folder in the views folder.
Paste it in your own views folder.
please check your folder name may have a space like like: localhost/code igniter/welcome
I just copied "errors" folder from "codeigniter3/application/views" in newly unzipped codeigniter3 folder and paste it into my project ("my_project/application/views"). It solved the problem :)
Create application / view / folder,
in errors folder, create html folder
create php filename error_php.php in the html folder
Check the routs.php file in application>config/routs.php file and change $route['default_controller'] = 'welcome'
to
$route['default_controller'] = 'your default controller name';
Related
I have a JAR file with below structure:
example.jar
|
+-org
| +-springframework
| +-boot
| +-loader.jar
+-BOOT-INF
+-classes
| +- kafka
| truststore.jks ==> I want to get the path here
+-lib
+-dependency1.jar
How can I get the configuration file path, only path (string) of 'kafka/truststore.jks' file ?
Because I am applying the SSL for KafkaProducer, I using below code and it work fine on local:
#Value("classpath:kafka/truststore.jks")
private org.springframework.core.io.Resource sslTruststoreResource;
...
String sslTruststoreLocation = sslTruststoreResource.getFile().getAbsolutePath(); // ==\> ***it throw FileNotFoundException here on deployed Server, local env run fine !***
Map\<String, Object\> config = Maps.newHashMap();
config.put("ssl.truststore.location", sslTruststoreLocation);
but when I deploy on Server, it throw FileNotFoundException :(
After many days to research, I found that the sslTruststoreResource.getFile() will be fail for JAR file case as mentioned at here
The sslTruststoreResource.getInputStream() or sslTruststoreResource.getFilename() are ok for JAR file but they are not path I need for kafka configuration.
In my project, the 'truststore.jks' file is located as below:
src
-- java
-- resources
. -- kafka
-- truststore.jks
So, is there any solution for my issue ? Thank you.
I tried to use ClassPathResource, ResourcePatternResolver but they not working
After many ways I still could not get the path from JKS file then I copy it to another path out of jar file where my code can refer to its path
final String FILE_NAME = env.getProperty("kafka.metadata.ssl.truststore.location");
String sslTruststoreLocation = "*-imf-kafka-client.truststore.jks";
try {
InputStream is = getClass().getClassLoader().getResourceAsStream(FILE_NAME);
// Get the destination path where contains JKS file
final String HOME_DIR = System.getProperty("user.home");
final Path destPath = Paths.get(HOME_DIR, "tmp");
if (!Files.isDirectory(destPath)) {
Files.createDirectories(destPath);
}
// Copy JKS file to destination path
sslTruststoreLocation = destPath.toFile().getAbsolutePath() + "/" + FILE_NAME;
File uploadedFile = new File(sslTruststoreLocation);
if(!uploadedFile.exists()) {
uploadedFile.getParentFile().mkdirs();
uploadedFile.createNewFile();
FileCopyUtils.copy(is, new FileOutputStream(sslTruststoreLocation));
log.debug("Copied {} file from resources dir to {} done !", FILE_NAME, sslTruststoreLocation);
}
config.put(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG, sslTruststoreLocation);
} catch (IOException e) {
final String message = "The " + sslTruststoreLocation + " file not found to construct a KafkaProducer";
log.error(message);
}
Looks like this is a known issue in Kafka.
Spring Boot propose a workaround similar to yours.
I am trying to convert .docx file to .pdf file by using dompdf and phpdocx. But I am getting error as -
file_put_contents(output_files/img6203609b73e9bc858.png): failed to open stream: No such file or directory {"exception":"[object] (ErrorException(code: 0): file_put_contents(output_files/img6203609b73e9bc858.png): failed to open stream: No such file or directory at C:\\xampp\\htdocs\\customer-api-2.0.1\\vendor\\phpdocx\\Classes\\Phpdocx\\Transform\\TransformDocAdvDOMPDF.php:478)
Here is my code -
require_once '../vendor/dompdf/dompdf/autoload.inc.php';
$docx = new \Phpdocx\Create\CreateDocx();
$path = storage_path('app');
$dompdf = new \Dompdf\Dompdf();
$transform = new \Phpdocx\Transform\TransformDocAdvDOMPDF($path.'\document.docx');
$transform->setDOMPDF($dompdf);
$transform->transform($path.'\document.pdf');
I am badly stuck here. Can anyone help me to resolve this error or suggest me any other alternative to achieve my aim
With this form element I'm uploading a file:
$element = new Zend_Form_Element_File('foo');
$element->setLabel('Upload Image1:')
->setDestination('/var/www/upload');
$element->addValidator('Count', false, 1);
$element->addValidator('Size', false, 102400);
$element->addValidator('Extension', false, 'jpg,png,gif');
$form->addElement($element, 'foo');
This requires that the folder is already existing.
How can I add an option, that the folder is beeing created, but only if a user selects a file and the upload succeeds?
You will have to remove ->setDestination from your form and put it in your controller.
The following is what you will put in your controller.
$upload = new Zend_File_Transfer_Adapter_Http();
if (//code to check if folder '/var/www/upload' does not exist)
{
//code to create a folder '/var/www/upload' and then set destination to that folder
$upload->setDestination('/var/www/upload');
}
I get the following error when trying to process uploaded images with imagick.
Fatal error: Uncaught exception 'ImagickException' with message 'unable to open image `9eK59iu.jpg': No such file or directory # error/blob.c/OpenBlob/2644' in D:\PATH\upload.php on line 77
The code looks like this:
<?php
$new_folder_name = "D:/PATH/content";
mkdir("$new_folder_name",0700);
$tmp_img = $_FILES["upload_file"]["tmp_name"];
$img = new Imagick($tmp_img);
$img->thumbnailImage(100 , 100 , TRUE);
$img->writeImage($new_folder_name);
?>
Without imagick the image upload works just fine.
Only imagick won't open the image given to $_FILES
I also tried to open the image with imagick, after move_uploaded_file, like this:
<?php
$extension = pathinfo($upload_file_name, PATHINFO_EXTENSION);
$new_upload_file_name = rand(00000, 99999).".".$extension;
$new_folder_name = "D:/PATH/content".time();
mkdir("$new_folder_name",0700);
$path_to_file = $new_folder_name."/".$new_upload_file_name;
move_uploaded_file($_FILES["upload_file"]["tmp_name"],$path_to_file);
$img = new Imagick($path_to_file);
$img->thumbnailImage(100 , 100 , TRUE);
$img->writeImage($new_folder_name);
?>
neither works.. :-(
Any suggestion?
Read the file upload docs. The server-side temporary filename assigned by PHP to store the uploaded file in ['tmp_name'] in the $_FILES array. You're trying to use the client-side user-provided ['name'], which DOES NOT exist anywhere on your server.
$tmp_img = $_FILES["upload_file"]["tmp_name"];
^^^^
You are also simply assuming that the upload has succeed. That is NOT a good thing. Never EVER assume success with dealing with remote resources (web apis, file uploads, database operations, etc...). ALWAYS check for errors:
if ($_FILES['upload_file']['error'] !== UPLOAD_ERR_OK) {
die("Upload failed with error code " . $_FILES['upload_file']['error']);
}
I moved my app from one server (develop) to other (release) and cake is falling in file lib/Cake/bootstrap.php which is one of cake core files.
the former address (which is running) is http://sdruzenid.kho.cz
at address http://sdruzenid.cz is the error.
I just copied all files from one server to other. There was no hard-coded addresses
At first server the adresar structure was
root: /sdruzenid
app: /sdruzenid/app
webroot: /sdruzenid/app/webroot
adresar www is not used (because the other web runs in it and this is just subdomain)
in new location it is
root: /www
app: /www/app
webroot: /www/app/webroot
when I print paths from app/webroot/index.php it is:
ROOT: /httpd/html/sdruzenidcz/www
WWW_ROOT: /httpd/html/sdruzenidcz/www/app/webroot/
CAKE_CORE_INCLUDE_PATH: /httpd/html/sdruzenidcz/www/lib:/httpd/html/sdruzenidcz:./
the error is cased by this code in lib/Cake/bootstrap.php
App::uses('ErrorHandler', 'Error');
App::uses('Configure', 'Core');
App::uses('CakePlugin', 'Core');
App::uses('Cache', 'Cache');
App::uses('Object', 'Core');
App::$bootstrapping = true;
the error is at last line. I cant find where variable $bootstrapping is defined or set but this is in cake core and on develop deploy it works fine
In my code app/webroot.index.php near error is:
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
if (function_exists('ini_set')) {
ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path'));
}
//it crashes after include of bootstrap.php
if (!include 'Cake' . DS . 'bootstrap.php') {
$failed = true;
}
} else {
if (!include CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php') {
$failed = true;
}
}
Delete all cache files on
app/tmp/cache/models
app/tmp/cache/persistent
The problem was simple. On hosting was low version of php. After upgrade all went fine.
So by short: If you have error in cake/core/bootstrapping.php on line 144, upgrade your php.