Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Zapisywanie zdjęć do folderu i galeria
Lampek
post
Post #1





Grupa: Zarejestrowani
Postów: 64
Pomógł: 0
Dołączył: 7.01.2011

Ostrzeżenie: (0%)
-----


Witam
Otóż mam na stronce upload zrobiony w jQuery i falshu. Zdjęcia zapisywane są do folderu upload. Chodzi mi o to, żeby każdy użytkownik mógł wyświetlać te foty w formie galerii oraz mógł je usuwać.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Lampek
post
Post #2





Grupa: Zarejestrowani
Postów: 64
Pomógł: 0
Dołączył: 7.01.2011

Ostrzeżenie: (0%)
-----


No dobra zmieniłem upload z uploadu do folderu na upload do bazy ale nic w bazie sie nie zapisuje :/
tu mam skrypt do uploadu u jQuery
  1. $(function(){
  2. $('#swfupload-control').swfupload({
  3. upload_url: "upload-file.php",
  4. file_post_name: 'uploadfile',
  5. file_size_limit : "1024",
  6. file_types : "*.jpg;*.png;*.gif",
  7. file_types_description : "Image files",
  8. file_upload_limit : 20,
  9. flash_url : "js/swfupload/swfupload.swf",
  10. button_image_url : 'js/swfupload/wdp_buttons_upload_114x29.png',
  11. button_width : 114,
  12. button_height : 29,
  13. button_placeholder : $('#button')[0],
  14. debug: false
  15. })
  16. .bind('fileQueued', function(event, file){
  17. var listitem='<li id="'+file.id+'" >'+
  18. 'Plik: <em>'+file.name+'</em> ('+Math.round(file.size/1024)+' KB) <span class="progressvalue" ></span>'+
  19. '<div class="progressbar" ><div class="progress" ></div></div>'+
  20. '<p class="status" >Oczekuję</p>'+
  21. '<span class="cancel" > </span>'+
  22. '</li>';
  23. $('#log').append(listitem);
  24. $('li#'+file.id+' .cancel').bind('click', function(){
  25. var swfu = $.swfupload.getInstance('#swfupload-control');
  26. swfu.cancelUpload(file.id);
  27. $('li#'+file.id).slideUp('fast');
  28. });
  29.  
  30. $(this).swfupload('startUpload');
  31. })
  32. .bind('fileQueueError', function(event, file, errorCode, message){
  33. alert('Rozmiar zdjęcia '+file.name+' jest większy niż dozwolony');
  34. })
  35. .bind('fileDialogComplete', function(event, numFilesSelected, numFilesQueued){
  36. $('#queuestatus').text('Wybranych zdjęć: '+numFilesSelected+' / Pliki w wrzucone: '+numFilesQueued);
  37. })
  38. .bind('uploadStart', function(event, file){
  39. $('#log li#'+file.id).find('p.status').text('Uploading...');
  40. $('#log li#'+file.id).find('span.progressvalue').text('0%');
  41. $('#log li#'+file.id).find('span.cancel').hide();
  42. })
  43. .bind('uploadProgress', function(event, file, bytesLoaded){
  44. //pokazuje postęp
  45. var percentage=Math.round((bytesLoaded/file.size)*100);
  46. $('#log li#'+file.id).find('div.progress').css('width', percentage+'%');
  47. $('#log li#'+file.id).find('span.progressvalue').text(percentage+'%');
  48. })
  49. .bind('uploadSuccess', function(event, file, serverData){
  50. var item=$('#log li#'+file.id);
  51. item.find('div.progress').css('width', '100%');
  52. item.find('span.progressvalue').text('100%');
  53. var pathtofile='<a href="uploads/'+file.name+'" target="_blank" >Zobacz ?</a>';
  54. item.addClass('success').find('p.status').html('Gotowe!!! | '+pathtofile);
  55. })
  56. .bind('uploadComplete', function(event, file){
  57. //upload zakończony
  58. $(this).swfupload('startUpload');
  59. })
  60.  
  61. });


a tutaj funkcje upload_file.php
  1. <?php
  2.  
  3. require_once('funkcje_all.php');
  4. $lacz = lacz_bd();
  5.  
  6. $fhandle = fopen($_FILES['zdjecie']['tmp_name'], "r");
  7. $content = base64_encode(fread($fhandle, $_FILES['zdjecie']['size']));
  8. fclose($fhandle);
  9. $zapytanie = $lacz->query("INSERT INTO zdjecia VALUES '".$content."'");
  10.  
  11. ?>


Ten post edytował Lampek 24.08.2011, 19:02:56
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 5.10.2025 - 04:11