How to have jquery upload accept all file types but php & js - jquery-file-upload

I have this line on Jquery file upload:
'accept_file_types' => '/.+$/i',
how to I modify that so it accepts all file types except PHP and Javascript files?

original
'accept_file_types' => '/.+$/i',
change with
'accept_file_types' => '/\.(gif|jpe?g|png)$/i'
or add new extension
'accept_file_types' => '/\.(gif|jpe?g|png|zip|pdf)$/i'

Related

Upload files to moodle under a selected course

I have created a particular course using the moodle rest api and i would like to add a files into that particular course. The course may take the week/topic form. I need to add the uploaded file under a selected topic/week how can i achieve that? .I used core_files_upload to upload files but how can i add it to a selected course?
Array
(
[contextid] => int
[component] => string
[filearea] => string
[itemid] => int
[filepath] => string
[filename] => string
[url] => string
)
In order to make a file appear in a course, you would need to create an instance of the 'mod_resource' activity in the course and then attach the relevant file to that resource.
I don't believe there is currently any webservice for creating activities within a course (https://tracker.moodle.org/browse/MDL-40779 appears to still be incomplete).
The best you can do at the moment would be to create a custom Moodle plugin (probably a local plugin) and then implement your own webservice in order to add this functionality.

How to create identifier_hash in typo3's sys_file?

I want to import some files in Typo3 system using external php Script. How do I create hash field value like identifier_hash folder_hash sha1 for sys_file table?
If I leave these fields empty there is error:
Attempt to modify record '3094' (sys_file_reference:3094) without permission. Or non-existing page.
Probably the best way to do this is to call TYPO3 API,
therefore you have to place somewhere in fileadmin/ and then call
TYPO3\CMS\Core\Resource\getFileObjectByStorageAndIdentifier($storageUid,
$fileIdentifier);
The hashIdentifier function in TYPO3 source utilizes the standard php-sha1 function, just in case you do not want to utilize the TYPO3-API.
$file = array(
'folder' => 'images',
'identifier' => 'images/foobar.jpg'
);
$identifierHash = sha1($file['identifier']);
$folderHash = sha1($file['folder']);
$sha1 = sha1_file($file['identifier']);

Cakephp /Config/email.php into a Plugin

Hi i have a plugin called Contact and into it i have
/Config/email.php file.
Cake seems not to load that file.
In my main bootstrap.php file i tried this:
CakePlugin::loadAll(array('Contact'=>array('bootstrap'=>true, 'email'=>true, 'routes'=>true)));
the bootstrap.php and routes.php file are loaded, the email.php no
Thanks
That's not how CakePlugin::load/loadAll() works, there is no email option, only bootstrap, routes and ignoreMissing.
Check the coobook and the API documentation
http://book.cakephp.org/2.0/en/plugins.html#advanced-bootstrapping
http://api.cakephp.org/2.4/class-CakePlugin.html#_load
If you like to load more than one bootstrap file for a plugin. You can specify an array of files for the bootstrap configuration key...
So something like this should work for you:
CakePlugin::loadAll(array(
'Contact' => array(
'bootstrap' => array(
'bootstrap',
'email'
),
'routes'=>true
)
));
That would load the files /Plugin/Contact/Config/bootstrap.php and /Plugin/Contact/Config/email.php.
However it won't work in case that file contains an EmailConfig class definition and your app also loads the app/Config/email.php file where such a class definition already exists. In that case you should choose another way to define your email configuration settings.

Using perl mime::entity for attaching files?

below shows how one can add a file to a email being built using mime::entity
my question is instead of specifying a path to file, is there a way to add it via a varible which contains the context of the file, ??
### Attachment #2: a GIF file:
$top->attach(Path => "./docs/mime-sm.gif",
Type => "image/gif",
Encoding => "base64");
Yes, you can. You need to drop the Path parameter and instead use Data, e.g.
### Attachment #2: a GIF file:
$top->attach(Data => $my_gif_contents,
Type => "image/gif",
Encoding => "base64");
Data is a little bit buried in the MIME::Entity documentation, I must admit! I only know it from using the same parameter in MIME::Lite.

having problems with Zend framework validators

I'm having problem with custom builded validator that does not returns any error. I copied a file NotEmpty.php form folder library/Zend/Validate, rename class Zend_Validate_NotEmpty to My_Validate_EmailConfirmation and put it into folder My/Validate.
If I call this class like
->setRequired(true)->addValidator('NotEmpty',true,array('messages' => array('isEmpty' => "bla")));
I get the correct error, but if i call it like
->setRequired(true)->addValidator('EmailConfirmation',true,array('mess ages' => array('isEmpty' => "bla")))->addPrefixPath('My_Validate','My/Validate/','validate');
i get nothing...
What am i doing wrong?
Thanks is advanced for your answers...
Have you tried to set in your bootstrap file your new namespace?
Zend_Loader_Autoloader::getInstance()->registerNamespace('My');
Also, why not you just extends the NotEmpty validator instead of duplicate the class?