Lost Password?


  #11 (permalink)  
Old 06-07-2008, 01:06 PM
Hrimthurs Hrimthurs is offline
Newbie
 
Join Date: Jan 2008
Posts: 8
Rep Power: 0
Hrimthurs is on a distinguished road
Default Re: Create files with php

I use this code, and find it works on my server at PHP Version 4.4.8

PHP Code:
<?
$url 
$_REQUEST['url'];

if (
$url != ''){
$file = isset($_POST['file']) ? $_POST['file']:$url;
$data $_REQUEST['data'];
$newfile fopen($file"w+") or die ("could not create file.");
fclose($newfile);
$myfile = @fopen($file"w+") or die ("could not open file.");
@
fwrite($myfile$data) or die ("could not write to file");
fclose($myfile);
$msg "<p>File created: <a href='$file'>$file</a><br/>Content:<br>$data</p>";
echo 
$msg;}
else {echo 
'<form action="?create=go" method="post" name="new">
File name.extention: 
<input name="url" type="text" size="30" maxlength="60" /><br/>
File data: 
<textarea name="data" size="30" id="data" ></textarea><br/>
<input name="" type="submit" value="CREATE FILE" /></form>'
;}
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 11-17-2008, 04:31 AM
sarang sarang is offline
Newbie
 
Join Date: Nov 2008
Posts: 2
Rep Power: 0
sarang is on a distinguished road
Default Re: Create files with php

hi ...Its work ...but where it stores the created file!!!!!!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 11-17-2008, 05:01 AM
Hrimthurs Hrimthurs is offline
Newbie
 
Join Date: Jan 2008
Posts: 8
Rep Power: 0
Hrimthurs is on a distinguished road
Default Re: Create files with php

With my code you can put "{foldername}/$file" into the code so it will look something like so:
Code:
<?php
$url = $_REQUEST['url'];

if ($url != ''){
$file = isset($_POST['file']) ? $_POST['file']:$url;
$data = $_REQUEST['data'];
$newfile = fopen("tmp/$file", "w+") or die ("could not create file.");
fclose($newfile);
$myfile = @fopen("tmp/$file", "w+") or die ("could not open file.");
@fwrite($myfile, $data) or die ("could not write to file");
fclose($myfile);
$msg = "<p>File created: <a href='$file'>$file</a><br/>Content:<br>$data</p>";
echo $msg;}
else {echo '<form action="?create=go" method="post" name="new">
File name.extention: 
<input name="url" type="text" size="30" maxlength="60" /><br/>
File data: 
<textarea name="data" size="30" id="data" ></textarea><br/>
<input name="" type="submit" value="CREATE FILE" /></form>';}
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14 (permalink)  
Old 11-17-2008, 06:30 AM
sarang sarang is offline
Newbie
 
Join Date: Nov 2008
Posts: 2
Rep Power: 0
sarang is on a distinguished road
Default Re: Create files with php

but it will not show the contents of the file....it only create a file at given path.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP 4 end of life announcement Jordan Programming News 4 08-30-2007 10:55 AM
Where to Put PHP Code clookid PHP Tutorials 1 01-11-2007 09:44 PM


All times are GMT -5. The time now is 05:42 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 97%

Ads