Nasıl sabit diskinizdeki klasörden dosyaları almak ve nasıl bir textarea içine yüklenen dosya verilerini görüntülemek için kullanabilirsiniz

1 Cevap

Ben, şifreniz e-posta id ve kullanıcının özgeçmiş için soruyorum hangi bir başvuru formu yaptık. Şimdi özgeçmiş yükledikten sonra ben bu username_filename gibi htdocs / uploadedfiles / ..in bir biçim şey içine sabit disk içine depolamak. Veritabanında ben dosya adı, dosya boyutu, dosya türünü depolamak. Bunun için bazı kodlama ben burada gösteriyorum

$filesize=$_FILES['file']['size'];
$filename=$_FILES['file']['name'];
$filetype=$_FILES['file']['type'];
$temp_name=$_FILES['file']['tmp_name'];   //temporary name of uploaded file
$pwd_hash = hash('sha1',$_POST['password']);        



$target_path = "uploadedfiles/";
$target_path = $target_path.$_POST['username']."_".basename( $_FILES['file']['name']); 

move_uploaded_file($_FILES['file']['tmp_name'], $target_path) ;   

$sql="insert into employee values    ('NULL','{$_POST[username]}','{$pwd_hash}','{$filename}','{$filetype}','$filesize',NOW())";

Now I have two questions 1.Now how can I display this file data into a textarea(something like naukri.com resume section)? 2.How one can retrieve that resume file from folder on hard-disk? What query should I write to fetch this file from that folder? I know how to retrieve data from database but I don't know how to retrieve data from a folder in hard-disk like in the case if user wants to delete this file or he wants to download this file. How I can do this?


Ben sorunun cevabını kendimi vermemelidir üzgünüm .. Ama çözüm için gerekli ..

$row=mysql_fetch_array($result);
$a='uploadedfiles/deepak.narwal_Deepak_resume revised'; //this is file name which i want to open.
$content = file_get_contents($a);

Bu ben bu dosyada depolanmış verileri görüntülemek için kullanılan budur

Resume
<textarea rows="50" cols="70" name="feedback"><?php echo $content; ?></textarea>

But when i execute the file following error is shown Warning: file_get_contents(uploadedfiles/deepak.narwal_Deepak_resume revised) [function.file-get-contents]: failed to open stream: No such file or directory in F:\Study Material\Linux\xampp\htdocs\test.php on line 26.But this file is in that directory i checked manully

i also tried like this
 $row=mysql_fetch_array($result);
    $a=row['File Path']; //this path is stored in database.file is there sure
    $content = file_get_contents($a);

1 Cevap

Eğer db dosyasının yolunu kazanılmış varsayarak:

$content = file_get_contents($path_to_file); bir dizeye dosyanın tüm içeriğini yükleyecektir $content. Daha sonra yapabilirdi:

<textarea>
<?php echo $content; ?>
</textarea>

görüntülemek için.

Eğer unlink($path_to_file);, doğrudan önce veya DB gerekli kayıt sildikten sonra ya (veya null dosyası yolu sütun ayarı) kullanmak bir dosyayı silmek için.

Şimdi bildiğim kadarıyla DB depolamak yolu olarak göreli yolunu kullanmak istemiyorum. Her zaman mutlak bir yol kullanabilirsiniz. böylece yerine:

$target_path = "uploadedfiles/";
$target_path = $target_path.$_POST['username']."_".basename( $_FILES['file']['name']);

Ne yapardın:

$target_path = "uploadedfiles/";
$target_path = realpath($target_path.$_POST['username']."_".basename( $_FILES['file']['name']));

Youll Ayrıca muhtemelen geldiğinde dosya ismi tek şey (boşluk, özel karakterler, vb) kaldırmak istiyor