Witam,
Mam skrypt który powinien wysyłać mi pliki ale to pliki audio i dostaje taki komunikat
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON dataTak wygląda mój skrypt do wysyłania.
jQuery(document).ready(function($){
$("#file").pekeUpload({
dragText:"Drag and Drop your files here",
bootstrap: true,
dragMode: true,
btnText: "Wybierz Plik",
allowedExtensions: "mp3",
invalidExtError:"Błąd w przesyłaniu plików",
maxSize: "25 MB",
showPreview: false,
showFilename:true,
showPercent:true,
showErrorAlerts:true,
errorOnResponse:"Wystąpił błąd przesyłania sprawdź plik i spróbuj ponownie",
url: "../includes/api/azuracast/upload.php",
//data:"path=" + file,
onFileError:function(file,error){
//alert(file,error);
var plik_error = JSON.parse(file)
console.log(plik_error);
},
onFileSuccess:function(file,data){
alert(file,data);
}
});
});
A tak do obierania pliku
require_once (INCLUDES.'api/azuracast/nowplaying.php');
$datap = dbarray(dbquery("SELECT * FROM ".DB_SETTING_PANEL_SERWER." WHERE id_user = '".$userdata['created_by']."'"));
$sciezka_plikow = storage_location($datap['numer_obslugi'],$datap['klucz_api']);
foreach($_FILES['file']['name'] as $key=>$val){
$file_name = '@' .$sciezka_plikow['path']."/".$_FILES['file']['name'][$key];
$tmpname = $_FILES['file']['tmp_name'][$key];
}
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "https://s1.twoj-host.pl/station/".$$datap['serwer_id']."/files");
//curl_setopt($ch, CURLOPT_HEADER, 0);
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt
($ch, CURLOPT_POSTFIELDS
, http_build_query
(array('path' =>$file_name , 'file'=>base64_encode
($tmpname)))); curl_setopt
($ch, CURLOPT_HTTPHEADER
, array( "Authorization: Bearer ".$datap['klucz_api'].""
));
// grab URL and pass it to the browser
$seve = curl_exec($ch);
$upload=json_encode($seve);
$data = json_decode($upload, true);
curl_close($ch);
I nie mogę zrobić co robię źle (IMG:
style_emoticons/default/questionmark.gif)
Ten post edytował pawel06281990 8.06.2024, 20:34:23