// enforce size limit from configuration, if defined $max = empty($config["max_meg_{$type}"]) ? '' : $config["max_meg_{$type}"]; if ($max) { $file_megs = round($file_size / (1024 * 1024)); if ($file_megs > $max) { $err = $type . ' files must be less than ' . $max . ' meg'; } } } if (!$err) { // try to move upload into its media directory and change permissions $path = path_concat(path_concat(path_concat(path_concat($config['web_root_directory'], $config['user_media_directory']), $uid), $id), $config['import_original_basename'] . '.' . $file_extension); if (!file_safe($path, $config)) { $err = 'Problem creating media directory'; } else { if (!file_move_upload($file['tmp_name'], $path)) { $err = 'Problem moving file'; } else { if (!file_mode($path, $config)) { $err = 'Problem setting permissions of media: ' . $path; } else { log_file('Saved to: ' . $path, $config); } } } $response['status'] = 'uploaded ok'; } if ($err) { $response['error'] = $err; } else { $response['ok'] = 1;
if (!file_move_extension($config['export_audio_extension'], $archive_dir, $media_dir, $config)) { $err = 'Could not move ' . $config['export_audio_extension'] . ' files from ' . $archive_dir . ' to ' . $media_dir; } else { if (!file_move_extension($config['export_extension'], $archive_dir, $media_dir, $config)) { $err = 'Could not move ' . $decoder_extension . ' files from ' . $archive_dir . ' to ' . $media_dir; } } } // remove the temporary directory we created, and any remaining files (there shouldn't be any) file_dir_delete_recursive($archive_dir); } } else { if ($file_ext != $config['export_audio_extension'] && $file_ext != $config['export_extension']) { $err = 'invalid file extension ' . $file_ext; } else { if (!file_move_upload($file['tmp_name'], $path_without_extension . '.' . $file_ext)) { $err = 'Problem moving uploaded file'; } } } } if (!$err) { // make sure we actually moved what we needed to, and change its permissions clearstatcache(); if (!file_exists($path_without_extension . '.' . $config['export_extension'])) { if (!file_exists($path_without_extension . '.' . $config['export_audio_extension'])) { $err = 'Did not generate file'; } } } if ($err) {