Mam problem w sprawie pobrania nowej nazwy pliku z PHP do JS
Mianowicie mam pewien skrypt JS ściągnięty z sieci który służy do wgrywania plików na serwer:
$().ready(function(){ $('#swfupload-control').swfupload({ upload_url: "upload-file.php", file_post_name: 'uploadfile', file_size_limit : "1024", file_types : "*.jpg;*.png;*.gif", file_types_description : "Zdjęcia", file_upload_limit : 3, flash_url : "js/swfupload/swfupload.swf", button_image_url : 'js/swfupload/XPButtonUploadText_61x22.png', button_width : 61, button_height : 22, button_placeholder : $('#button')[0], debug: false }) .bind('fileQueued', function(event, file){ var listitem='<li id="'+file.id+'" >'+ 'Zdjęcie: <em>'+file.name+'</em> ('+Math.round(file.size/1024)+' KB) <span class="progressvalue" ></span>'+ '<div class="progressbar" ><div class="progress" ></div></div>'+ '<p class="status" >Czekaj ...</p>'+ '<span class="cancel" > </span>'+ '</li>'; $('#log').append(listitem); $('li#'+file.id+' .cancel').bind('click', function(){ var swfu = $.swfupload.getInstance('#swfupload-control'); swfu.cancelUpload(file.id); $('li#'+file.id).slideUp('fast'); }); // start the upload since it's queued $(this).swfupload('startUpload'); }) .bind('fileQueueError', function(event, file, errorCode, message){ alert('Plik '+file.name+' jest za duży'); }) .bind('fileDialogComplete', function(event, numFilesSelected, numFilesQueued){ $('#queuestatus').text('Ilość wybranych plików: '+numFilesSelected+' / Ilość zakończonych: '+numFilesQueued); }) .bind('uploadStart', function(event, file){ $('#log li#'+file.id).find('p.status').text('Proszę czekać...'); $('#log li#'+file.id).find('span.progressvalue').text('0%'); $('#log li#'+file.id).find('span.cancel').hide(); }) .bind('uploadProgress', function(event, file, bytesLoaded){ //Show Progress var percentage=Math.round((bytesLoaded/file.size)*100); $('#log li#'+file.id).find('div.progress').css('width', percentage+'%'); $('#log li#'+file.id).find('span.progressvalue').text(percentage+'%'); }) .bind('uploadSuccess', function(event, file, serverData){ var item=$('#log li#'+file.id); item.find('div.progress').css('width', '100%'); item.find('span.progressvalue').text('100%'); var pathtofile='<a href="picture/szukam_pracy/'+file.name+'" target="_blank" >podgląd »</a>'; item.addClass('success').find('p.status').html('Gotowe!!! | '+pathtofile); }) .bind('uploadComplete', function(event, file){ // upload has completed, try the next one in the queue $(this).swfupload('startUpload'); }) });
do tego dochodzi taki plik php
$uploaddir = './picture/szukam_pracy/'; $size=$_FILES['uploadfile']['size']; if($size>1048576) { exit; } $plik1_tmp = $_FILES['uploadfile']['tmp_name']; $plik_foto1 = $_FILES['uploadfile']['name']; $zrodlo="picture/szukam_pracy/".$los.$plik_foto1; } else { echo "error ".$_FILES['uploadfile']['error']." --- ".$_FILES['uploadfile']['tmp_name']." %%% ".$file."($size)"; }
Zmodyfikowałem go troche o wygenerowanie losowej nazwy pliku i teraz nie wiem jak zwrócic ta nazwe do JS
jak zmienić $_FILES['uploading']['name'] ze starej na nową.
Nie chce zeby mi ktos pisal kod tylko porsil bym o podpowiedz z czego skorzystac i czy jest wogole taka mozliwosc