PHP kullanarak bir dosya sistemi üzerinde saklayarak olmadan bir FTP Server için bir dosya yükleme

2 Cevap php

Ben Unsuccesfully (güvenlik etkileri vardır) ilk dosya sistemine yazmadan, bir FTP sunucusuna şifreli bir dosyayı yüklemeye çalışıyorsunuz edilmiştir

I [(3)] proc_open kullanmaya çalışıyorsunuz ve ardından ftp_fput ama proc_open oluşturulan akışı {olmadığı için boşuna, sanırım edilmiştir } mümkün

İşte kod

<?php
$ciphertext = 'sadfasfasdf90809sf890as8fjwkjlf';

//The Descriptors
$descriptorspec = array( 
  0 => array("pipe", "r"),  // stdin 
  1 => array("pipe", "w"),  // stdout 
  2 => array("pipe", "w")   // error
);

$process = proc_open('cat', $descriptorspec, $pipes);
if (is_resource($process)) {    
fwrite($pipes[0], $ciphertext); 
fclose($pipes[0]);

//Debug test to proce that $pipes[1] is a valid stream     
//while(!feof($pipes[1])) {
//  $content .=  fgets($pipes[1],1024);
//}

//FTP connection etc etc OMMITTED to save space.

$upload = @ftp_fput($conn_id,$dir."/".$ftp_file.$extenstion,$pipes[1],FTP_BINARY);
fclose($pipes[1]);
// Check upload status
echo ('upload '. ($upload ? 'true':' false')); 
}
?>

Birisi herhangi bir yenilik ya da alternatif yöntemler yardımcı veya önerebilirsiniz umuyoruz.

Teşekkürler,

Phil

2 Cevap

Bir sunucu yönetici asla güvenme!

Yukarıdaki kod çalışır ve bir tmpfile kullanmayı gerektirmez.

Teşekkürler,

Phil

Neden bir dosya oluşturmak istemiyorum olduğunu? Bir alternatif, güvenlik nedenleri, ya da başka bir şey yok çünkü sadece mı?

Ben genellikle dosya sistemi zaten olmayan FTP dosya upload yolu kullanarak tmpfile edilir:

<?php

  $fh = tmpfile();
  fwrite($fh, data);

  // do upload

  fclose($fh);

?>

Geçici bir dosya kullanarak yapar oldukça temiz; Eğer dosyayı kapatın, yükleme yazmak gerekir ne olursa olsun yazmak ve sonra yapmanız sihirli kaybolur.

Eğer dosya (bellek yani veri) 'den bir FTP sunucusu başka şeyler yükleyebilirsiniz Şimdi eğer, en azından ben bir yol bulmaya çalıştım ama yapamadım ... Bilmiyorum.