Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [CI][CodeIgniter] Ocena jakości kodu
tabbi
post
Post #1





Grupa: Zarejestrowani
Postów: 150
Pomógł: 3
Dołączył: 30.10.2010

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


Witam,

chciałbym zapytać czy np. progress wgrywania pliku na serwer uploadu np. megaupload.com oparty o SESJE albo np. o MEMCACHED jest dobrym rozwiązaniem. ? Tzn. proces wgrywania pliku to pętla while która czyta plik:

  1. while ( ! feof ( $fs ) ) {
  2. $data = fread ( $fs, $chunkSize );
  3. if ($data === false) {
  4. fclose ( $fs );
  5. fclose ( $fp );
  6. }
  7.  
  8.  
  9. $sendbyte = fputs ( $fp, $data );
  10. fflush ( $fp );
  11.  
  12. if ($sendbyte === false) {
  13. fclose ( $fs );
  14. fclose ( $fp );
  15. }
  16.  
  17. $totalsend += $sendbyte;
  18.  
  19.  
  20. $percent = round ( $totalsend / $fileSize * 100, 2 );
  21. $this->CI->memcached_library->set('progress/'.$uid, $percent, 10);
  22.  
  23. flush ();
  24.  
  25. }


Całość jest odczytywana poprzez zapytanie wysyłane poprzez javascript .get() - funkcje jquery

Metoda:

  1. *
  2. * We receive uid with hostid and give back progress status of file !
  3. *
  4. * @param string $uid (uri segment 3) - The uid of file
  5. * @return int - Procent of progress
  6. */
  7. public function progress_status()
  8. {
  9.  
  10. $uid = $this->uri->segment(3);
  11.  
  12. if(empty($uid))
  13. {
  14. echo 0;
  15. exit();
  16. }
  17.  
  18. // We download the progress status from Memcached !
  19. echo $progress = $this->memcached_library->get('progress/'.$uid);
  20.  
  21. // We delete the cache file
  22. if($progress == 100)
  23. {
  24. $this->memcached_library->delete('progress/'.$uid, NULL);
  25. }
  26. }


Czekam na opinie ?
Go to the top of the page
+Quote Post
el.pablo.72
post
Post #2





Grupa: Zarejestrowani
Postów: 8
Pomógł: 0
Dołączył: 1.11.2010

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


Jeśli chcesz umieszczać hurtem pliki na serwerze to pomyśl nad innym rozwiązaniem. W CI masz klasę: http://codeigniter.com/user_guide/librarie..._uploading.html i dodatkowo użyć AJAX.
Go to the top of the page
+Quote Post
tabbi
post
Post #3





Grupa: Zarejestrowani
Postów: 150
Pomógł: 3
Dołączył: 30.10.2010

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


Tak użyłem tej klasy + uploadify do wgrywania plików na serwer, jednak później te pliki są wysyłane na serwery typu megaupload itp... wysyłanie poprzez stream z socketu i zczytywanie pliku.
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 21.08.2025 - 11:01