CkEditor 5 image upload forbidden 403 - yii2

I am using this ckeditor
but cant upload image. The error I get is 403 forbidden. Gave 777 permission to my folder but still the same thing. How should I upload an image ?
Code:
<?= $form->field($model, 'description')->widget(
EditorClassic::class,
[
'uploadUrl' => "http://travel.toma.com/backend_images/ckeditor"
]
);
?>

Related

How to make Custom 404 err page without .htaccess file [duplicate]

I want to show the 404 page when user enters unknown address like on the above image.
I can control the unknown address after index.php but don't know how to do this for the part before the index.php part.
I wrote this code to control what user enters after index.php
<?php
$pageName = 'places';
if (isset($_GET['page'])) {
$pageName = $_GET['page'];
}
$pageList = array(
'places',
'places_info',
'save'
);
if (!in_array($pageName, $pageList)) {
$pageName = '404';
}
?>
It looks like you have apache on your development machine.
The way to have custom error pages is
Create/Edit the file in C:\xampp\htdocs\blit\.htaccess
Insert a line ErrorDocument 404 /blit/404.shtml
Create the file C:\xampp\htdocs\blit\404.shtml
Put whatever html you want in it.
Repeat for other errors.
If you type in localhost/blit/xxy and xxy.php and xxy.html do not exist then the error page will be shown.

Yii2 Noam Image manager save outside web folder

I use noam image manager for my yii2 app
https://github.com/noam148/yii2-image-manager
and in the components , they told me to put this
'components' => [
'imagemanager' => [
'class' => 'noam148\imagemanager\components\ImageManagerGetPath',
//set media path (outside the web folder is possible)
'mediaPath' => '/path/where/to/store/images/media/imagemanager',
//path relative web folder to store the cache images
'cachePath' => 'assets/images',
//use filename (seo friendly) for resized images else use a hash
'useFilename' => true,
//show full url (for example in case of a API)
'absoluteUrl' => false,
],
],
and i tried so many times to make the extension create folder outside the web folder , and always not working , can somebody help me on this ?
i found the way to move the target , all you have to do is make link shortcut in config files, and use it in params file , and also you can modified the model in the composer files directly

Chrome notifications API img

I'm trying to fire a chrome notification ( in a chrome extension ) with the following code:
var opt = {
type: "basic",
title: "Deploy",
message: "It worked!",
iconUrl: "test.png"
};
chrome.notifications.create("", opt, function(id) {
//console.error(chrome.runtime.lastError);
});
But it shows me the following message :
"Unchecked runtime.lastError while running notifications.create: Unable to successfully use the provided image. "
My image "test.png" is in the root folder of my app( with the manifest.json file ), but I've tried to put the picture also in other folder of my app, it never worked!
I've correctly added the permission for notifications, so I really don't know where the problem is !
Any ideas ?
Thank you,
EDIT: I found the solution ! The image needed to be 80*80 !

How can I use html5 cache manifest with CakePHP?

I want to use the html5 cache manifest technology with CakePHP,
but I don't know where to place the cache manifest in CakePHP,
I've searched for a solution, but I do not found anything.
Can you help me?
The best and easiest way to access one manifest file in all views is to look at your layouts, for example
View/Layouts/default.ctp
and replace <html> with
<?php echo "<html manifest='".$this->webroot."manifest.php'>"; ?>
in which manifest.php is located in
app/webroot/manifest.php
and looks something like this:
<?php
header('Content-Type: text/cache-manifest');
echo "CACHE MANIFEST\n";
echo "\n\nNETWORK:\n";
echo "*\n";
echo "\n\nCACHE:\n";
echo "# Version: 1\n";
?>
So the manifest.php is only needed once and can be used for all views.
HINT:
For a dynamic manifest-file you can use a code snippet from here:
http://nial.me/2010/01/using-the-html5-cache-manifest-with-dynamic-files/
I tried this solution, putting the manifest in default.ctp, but it causes some problems, all my pages was cached... i think it's discribed in the spec "...the page that referenced the manifest is automatically cached even if it isn't explicitly mentioned".
...couse this all my pages was being cached, manifest is checked in each page. And when another user logs in they see the last user homepage and other pages.
The final solution: create a redirect/loading page
1 - create the redirect page:
I had create the Pages/redirect.ctp file and the function redirect(){} in the Pages controller. A simple page, just with a hello message and a loading bar based on the applicationCache progress event:
var appCache = window.applicationCache;
appCache.addEventListener('progress', function(event) {
console.log(event.loaded + " of " + event.total + " files...");
//make some changes in the page' loading bar
}, false);
2 - Load manifest only in the redirect page:
In the View/Layouts/default.ctp I filtered the tag to show the manifest only in the redirect page:
<? if($this->request->params['controller']=='pages' &&
$this->request->params['action']=='redirect'): ?><html
manifest="<?=$this->webroot?>manifest.php">
<? else: ?>
<html >
<?
endif; ?>
3 - Use the redirect page in the auth component to lead my user
to redirect page after login:
In the appController a setted auth component like this
public $components = array (
'Session',
'Auth' => array (
'authError' => "user or password invalid",
'unauthorizedRedirect' => "/pages/redirect?err=login",
'loginRedirect' => "/pages/redirect",
'logoutRedirect' => "/",
'loginAction' => "/user/login",
'authorize' => array ('Controller')
)
);
now only the elements putted in the manifest will be cached. The redirect page is cached (according the spec) but the applicationCache event updates the page torning this "dinamic".
If you mean the manifest file it should go into /app/webroot, the directory that your vhost should also use for the site. besides this there is nothing really related to CakePHP with this.
Have a look at this: http://www.html5rocks.com/en/tutorials/appcache/beginner/

Saving an image from Flash on the server under different name

I followed this question:
flash Actionscript 3 and php image upload
I copied the code:
function uploadFile( e:Event ):void
{
fileRef.upload( new URLRequest( "http://localhost/php5dev/test/upload_script.php" ), "as3File", false );
}
and
<?php
$target = "uploads/" . basename( $_FILES[ "as3File" ][ "name" ] );
if ( move_uploaded_file( $_FILES[ "as3File" ][ "tmp_name" ], $target ) )
echo( "file upload success<bt />" );
else
echo( "error uploading file<br />" );
?>
It works great, I just need to know how to save the image under a specific name, how do I pass an argument to the php script? or is that not necessary, can I change it before calling the script?
How would I then call URLrequest to show user the file he uploaded ?
Thanks, for any answers!
You could send the filename via a GET query:
fileRef.upload( new URLRequest( "http://localhost/php5dev/test/upload_script.php?filename=myFile.txt" ), "as3File", false );
And then retrieve it in PHP as $_GET['filename'];
As a word of advice, be careful with those scripts since they are very insecure (one could upload any file to your server and exploit it very easily).