How can i fix svg image upload error in wordpress? - image

How to Fix the “Sorry, this file is not permitted for security reasons” WordPress Error
define('ALLOW_UNFILTERED_UPLOADS', true);

# How to fix ( Sorry, you are not allowed to upload this file type ) Error
# // SVG File Uploads Code
Site Tools > Site > File Manager >
## or goto c-panel and file manager then =
## public_html/wp-includes/functions.php
Then past this code and save
function add_file_types_to_uploads($file_types){
$new_filetypes = array();
$new_filetypes['svg'] = 'image/svg+xml';
$file_types = array_merge($file_types, $new_filetypes );
return $file_types;
}
add_filter('upload_mimes', 'add_file_types_to_uploads');

Related

October CMS issue with file attachment during tests

I am using October CMS
I have a model which has some attachOne and attachMany file attachments.
Both of these work fine during normal use.
However I am having difficulty with setting up tests
I have the following code in my test class
$logo = file(__DIR__ . '/assests/images/logo.png');
$file = new System\Models\File;
$file->data = __DIR__ . '/assests/images/Sample-Photo.jpeg';
$file->is_public = 1;
$file->save();
$nhd->developer_logo = (new System\Models\File)->fromData($logo, 'logo.png');
$nhd->development_photos->add($file);
$nhd->save();
$developer_logo_path = $nhd->developer_logo->getPath();
$photo_path = $nhd->development_photos[0]->getPath();
Both the ‘$developer_logo_path’ and ‘$photo_path’ variables successfully return a stored file path ( which actually points to a file which has been saved ) which is what i would except.
However if i then let the test run and execute the normal code. If I put a breakpoint in the component php file at the point after the model referred to in the test code as $nhd has been loaded there is a ‘developer_logo’ attached ( the AttachOne file ) but there are no ‘development_photos’ ( the attachMany file ).
As a result the template also does not output anything when {{component.development_photos}} is used
I also tried using the inline method to add the attachMany file ( $nhd->development_photos = (new System\Models\File)->fromData($photo, ‘logo.png’); ) and this also did not work.
Can anyone help me?

Appcelerator - File storage fail

I copy a video into /Documents/videos/xxxxxx.mp4 and then, when I close the app and restart it, this error appear when I want to get the file:
nativeReason = "Could not open file stream for file at path: /var/mobile/Containers/Data/Application/055CE45C-28EC-46F5-9609-F16E357B682E/Documents/videos/1458044667778.mp4\nFile does not exist at path /var/mobile/Containers/Data/Application/055CE45C-28EC-46F5-9609-F16E357B682E/Documents/videos/1458044667778.mp4";
But I can see this file at the directory:
Whats the problem?? This occur on iOS, Ti.SDK 5.2.0.GA
My code:
if(OS_IOS){
Ti.API.debug("Media: " + this.get("media").nativePath);
var infile = Ti.Filesystem.getFile(this.get("media").nativePath); //!
}else{
var infile = Ti.Filesystem.getFile(this.get("media"));
}
Ti.API.debug('infile: ' + infile.exists());
var tempFile = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, "videos/");
if(!tempFile.exists())
tempFile.createDirectory(); //create videos directory
var tempFile = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, "videos/" + new Date().getTime() + ".mp4");
Ti.API.debug('tempFile ' + tempFile.exists()); // tempsFile is always empty
if(OS_IOS){
if (infile.exists() && (!tempFile.exists()) ) { //copy infile to videos/
tempFile.write(infile.read());
}
}else{ //Android
infile.copy(tempFile.nativePath); //copy infile to videos/
}
//Get video, the path saved is correct
var vid = Ti.Filesystem.getFile(video.get("videoFile"));
By default Ti.Filesystem.getFile() all relative paths are currently interpreted as relative to the Resources directory, not to the current context. This is a known issue that will be addressed in a future release. : http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Filesystem-method-getFile
So, you need to save the video file name in video.get("videoFile") and get the video this way : Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, "videos/"+video.get("videoFile"));

Codeigniter error log not working

I want to log my details for log my application event. So i have changed config.php as follows.
$config['log_threshold'] = 4;
$config['log_path'] = 'application/logs/main';
$config['log_date_format'] = 'Y-m-d H:i:s';
I use it in my controller as like this.
log_message('error', 'Some variable did not contain a value.');
I grant write permission to main file. bt it is not working. What is the issue.
log_path is meant to be a folder not a file. If main is a folder then you should add a trailing /

ftp transfer using codeigniter version 2

$this->load->library('ftp');
$config['hostname'] = 'text.com';
$config['username'] = 'test';
$config['password'] = '12345678';
$config['port'] = 21;
$config['passive'] = FALSE;
$config['debug'] = TRUE;
$conn = $this->ftp->connect($config);
if($conn){
$this->ftp->upload('/ftp1_uploads/images/test.zip','/ftp2_uploads/images/test.zip');
}
I want to transfer from ftp1 to ftp2 not the same domain.
Return error below using codeigniter version 2
An Error Was Encountered
Unable to locate the source file. Please check your path.
I already try rename the file using the same path its works. but when I transfer from ftp1 to ftp2 different domain it will not work.
You can't transfer files from ftp1 to ftp2 without using interim location, your algorithm is: download from ftp1 to local, upload from local to ftp2

exportDocument() 'destination folder does not exist' error

I'm trying to make a script in photoshop that will modify some layers and than export them as a PNG image. I've copied the following code from another place:
function SavePNG(saveFile){
var pngOpts = new ExportOptionsSaveForWeb;
pngOpts.format = SaveDocumentType.PNG
pngOpts.PNG8 = false;
pngOpts.transparency = true;
pngOpts.interlaced = true;
pngOpts.quality = 100;
activeDocument.exportDocument(saveFile,ExportType.SAVEFORWEB,pngOpts);
}
The function export the active document of photoshop to the file specified by the saveFile parameter.
It's working fine with simple paths like "C:\images\result.png" but when trying with different paths like "~/Desktop/" or paths with some special characters the file isn't exported, and a "destination folder does not exist" error message appears.
Any idea how can I solve it?
Well, I'm not sure why this is occur but you could try the following modification:
function SavePNG(saveFile){
var tmpFile = "./tmp.png";
tmpFile = new File(tmpFile);
var pngOpts = new ExportOptionsSaveForWeb;
pngOpts.format = SaveDocumentType.PNG
pngOpts.PNG8 = false;
pngOpts.transparency = true;
pngOpts.interlaced = true;
pngOpts.quality = 100;
activeDocument.exportDocument(tmpFile,ExportType.SAVEFORWEB,pngOpts);
tmpFile.rename (saveFile);
tmpFile.changePath(saveFile);
}
it'll export the file into a temporary file and then rename & move it to the requested path, should solve the path problem.
exportDocument expects a full file name, not a folder path.
This works:
activeDocument.exportDocument(new File("~/foo/foo.png"), ExportType.SAVEFORWEB, pngOpts);
This doesn't work and gives the 'destination folder does not exist' error message:
activeDocument.exportDocument(new File("~/foo/"), ExportType.SAVEFORWEB, pngOpts);
For people having this error and not using photoshop-script.
The error might be unbound to the destination folder, but occurs because the folder, which was used for the export step, is deleted. So either
recreate the folder, which was used during recording, or
recreate the export step

Resources