fix name save file
This commit is contained in:
parent
b9ed728e86
commit
43bb2ab021
|
|
@ -47,14 +47,6 @@ class Audio_Diary_Admin_Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function handle_download_zip() {
|
function handle_download_zip() {
|
||||||
if (!current_user_can('manage_options')) {
|
if (!current_user_can('manage_options')) {
|
||||||
|
|
@ -195,6 +187,7 @@ class Audio_Diary_Admin_Page {
|
||||||
wp_mkdir_p($audio_dir);
|
wp_mkdir_p($audio_dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function save_audio() {
|
public function save_audio() {
|
||||||
if (!current_user_can('manage_options')) {
|
if (!current_user_can('manage_options')) {
|
||||||
wp_send_json_error('Unauthorized');
|
wp_send_json_error('Unauthorized');
|
||||||
|
|
@ -210,22 +203,18 @@ public function save_audio() {
|
||||||
$uploads = wp_upload_dir();
|
$uploads = wp_upload_dir();
|
||||||
$upload_path = $uploads['basedir'] . '/audio-diary/';
|
$upload_path = $uploads['basedir'] . '/audio-diary/';
|
||||||
|
|
||||||
// Check if the directory exists, if not create it
|
$date_time = date('Y-m-d H-i-s');
|
||||||
if (!file_exists($upload_path)) {
|
$file_name = 'memory-' . $date_time . '.wav';
|
||||||
wp_mkdir_p($upload_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
$file_name = 'audio-' . time() . '.wav';
|
|
||||||
$file_path = $upload_path . $file_name;
|
$file_path = $upload_path . $file_name;
|
||||||
|
|
||||||
// Move the uploaded file to the audio-diary directory
|
|
||||||
if (move_uploaded_file($file['tmp_name'], $file_path)) {
|
if (move_uploaded_file($file['tmp_name'], $file_path)) {
|
||||||
wp_send_json_success('File uploaded');
|
wp_send_json_success(['message' => 'File uploaded', 'file_name' => $file_name]);
|
||||||
} else {
|
} else {
|
||||||
wp_send_json_error('File upload failed');
|
wp_send_json_error('File upload failed');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Audio_Diary_Admin_Page::get_instance();
|
Audio_Diary_Admin_Page::get_instance();
|
||||||
Loading…
Reference in New Issue