2016-06-14 82 views
0

我一直在嘗試將輸入聯繫人保存爲文件夾中的文件,但我不知道如何使用php進行此操作。將文本轉換爲文件並將其保存到文件夾中

<php 
if(isset($_POST['s'])){ 
$neexe = $_POST['nameextention']; 
$filecont = $_POST['fileBody']; 

$folderpath = 'Files'; 
// I wan to save this as page.php with the body content inside so users can download it 

} 
?> 

<form method="post"> 
<input type="text" name="nameextention" value="page.php"/> 
<textarea name="fileBody"><?php if(isset($_HELP['please'])){echo 'i really need to get this done!!';}?></textarea> 
<input type="submit" name="s" value="Save"> 
</form> 
+0

要保存測試TEXTFILE雅PDF – iOS

回答

0

簡單。使用的fopen如下內置功能:

$myfile = fopen($neexe, "w") or die("Failed to open file!"); 
fwrite($myfile, $filecont); 
fclose($myfile); 
+0

哦,這太好玩了,很簡單的代碼做的感謝,請什麼有關文件夾路徑? – Frank

+0

請指出保存我的新文件的文件夾路徑@Ratul Doley – Frank

+0

將其預先加到文件名'$ fileDirectory。$ neexe'中。如果你沒有指定路徑,它將被寫入與你的腳本相同的目錄中 – ksealey

相關問題