Current location: Hot Scripts Forums » Programming Languages » PHP » How do i open a file?


How do i open a file?

Reply
  #1 (permalink)  
Old 05-21-06, 01:08 PM
xxvatarxx xxvatarxx is offline
Wannabe Coder
 
Join Date: May 2005
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
How do i open a file?

What i want is for a user to upload a file, then for the php to open that file and strip certain tags and then output in the browser the remaining code.
It's all done except i don't know how to let the php open the file and edit the contents
Reply With Quote
  #2 (permalink)  
Old 05-21-06, 01:19 PM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
...

Fine, use your own code then.

Last edited by Keith; 05-21-06 at 01:21 PM.
Reply With Quote
  #3 (permalink)  
Old 05-21-06, 01:19 PM
xxvatarxx xxvatarxx is offline
Wannabe Coder
 
Join Date: May 2005
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
doesn't matter, i've got the code i need now...
Reply With Quote
  #4 (permalink)  
Old 05-21-06, 01:20 PM
xxvatarxx xxvatarxx is offline
Wannabe Coder
 
Join Date: May 2005
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
thats different to the code i have

I'll try mine first... then i'll use that when what i have doesn't work

EDIT: Geeze thanks, can you re-post it? i may need it

FFS your a <<word>> tbh

Last edited by Christian; 05-21-06 at 01:32 PM.
Reply With Quote
  #5 (permalink)  
Old 05-21-06, 01:22 PM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
Quote:
Originally Posted by xxvatarxx
FFS your a <<word>> tbh
Haha! I take time out of my day to type up working code for you that does exactly what you want, and your reply is "doesn't matter"? So who's the <<word>>? Maybe someone else will help you, but it won't be me.

Last edited by Christian; 05-21-06 at 01:32 PM.
Reply With Quote
  #6 (permalink)  
Old 05-21-06, 01:27 PM
xxvatarxx xxvatarxx is offline
Wannabe Coder
 
Join Date: May 2005
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
i never saw ur reply, i never refreshed the page -.-

U really weren't meant to get offended -.-
Reply With Quote
  #7 (permalink)  
Old 05-21-06, 01:30 PM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
Alright, that makes sense...

PHP Code:

<?php


$uploadedFile 
'/path/to/file.txt';

$contents file_get_contents($uploadedFile);

$contents preg_replace("/<p(.*)>(.*)</p>/Ui""\\2"$contents); // remove <p></p> combos

echo $contents;

?>
Untested, but it should work and is a simple guide for what you're looking to accomplish.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with my largest perl script. Grabbing data from a file. Sunnmann Perl 2 04-23-08 03:27 AM
How To Open HTML File & Edit Once a Day cebuy PHP 2 12-13-04 04:03 PM
Open File ogre0038 Script Requests 3 10-28-04 08:27 PM
Server open file altafingar ASP.NET 1 10-20-04 12:12 AM
How to open a file?? bonnie ASP 10 06-17-03 05:14 AM


All times are GMT -5. The time now is 07:15 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.