33 lines
910 B
PHP
Executable File
33 lines
910 B
PHP
Executable File
<?php
|
|
|
|
session_id($_POST[session_name()]);
|
|
$func = include('includes/auth.php');
|
|
$func(function () {
|
|
|
|
ETPA::skipLog();
|
|
$id = uniqid();
|
|
$infos = pathinfo($_FILES['Filedata']['name']);
|
|
$source = $_FILES['Filedata']['tmp_name'];
|
|
$ext = strtolower($infos['extension']);
|
|
$target = './db.media/' . $id . '.' . $ext;
|
|
|
|
if ( !in_array($ext, array('jpg', 'jpeg', 'png', 'gif', 'pdf', 'mp4', 'mpeg4', 'mp3')) )
|
|
die('Type de fichier interdit !');
|
|
move_uploaded_file($source, $target);
|
|
|
|
if ( !empty($_POST['multi']) ) {
|
|
|
|
$data = array();
|
|
foreach ( json_decode($_POST['data'], 1) as $pair )
|
|
if ( preg_match('!^objects\[\d++\]\[(.+)\]$!', $pair['name'], $m) )
|
|
$data[$m[1]] = $pair['value'];
|
|
|
|
Model::get($_POST['model'])->Service->crud->create(array_merge($data, array(
|
|
Model::get($_POST['model'])->getData('multi') => $_POST['url'] . $id,
|
|
)));
|
|
|
|
}
|
|
|
|
die('ok:' . $id . '.' . $ext);
|
|
|
|
}); |