How we can upload a text file or word file using php Code???

Reply

Join Date: Feb 2009
Posts: 130
Reputation: gagan22 is an unknown quantity at this point 
Solved Threads: 0
gagan22 gagan22 is offline Offline
Junior Poster

How we can upload a text file or word file using php Code???

 
0
  #1
Jun 9th, 2009
Hi all,

Yesterday i was working in which i need some application in which we can upload image file in our system. That is working very well.

But now i want to upload a notepad text file or ms-word file from system to server.
Means I want to upload a text file that can be in .txt, .xls or .doc format. That i want to upload from my system and after uploading that file and i want to show that file on that page from which page i am uploading that file.

All of this i want to do using PHP code . I know just i should use move_upload function for image uploading . But i do not know in correct function of uploading text files how i should use this function.
So Please help me to solve this problem. I will be thankful of that person who will he help me on this topic because i am doing such type of work first time.
So please help me.
Thanks,
Gagan
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,721
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 501
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven

Re: How we can upload a text file or word file using php Code???

 
0
  #2
Jun 9th, 2009
The same way you upload images you can upload other files.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 144
Reputation: HITMANOF44th is an unknown quantity at this point 
Solved Threads: 19
HITMANOF44th HITMANOF44th is offline Offline
Junior Poster

Re: How we can upload a text file or word file using php Code???

 
0
  #3
Jun 9th, 2009
if you wrote your previous script to only handle .jpg .gif or image formats you can change it around so it can handle all extensions
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 68
Reputation: djjjozsi is an unknown quantity at this point 
Solved Threads: 10
djjjozsi djjjozsi is offline Offline
Junior Poster in Training

Re: How we can upload a text file or word file using php Code???

 
0
  #4
Jun 9th, 2009
if you uploaded a file, $_FILES["filevalue"]["type"] gives you back your file's type. If you upload a word doc, its type is application/msword:

$allowed_types=array(
"image/jpeg",
"image/gif",
"image/png",
"text/plain",
"application/msword",
"application/vnd.ms-excel");

how to check it its allowed:
if(isset($_FILES["filevalue"]["type"]))
{
if(! in_array($_FILES["filevalue"]["type"] , $allowed_types))
{
die("You need to upload word/excel/plain text/ images only");
}
}
Last edited by djjjozsi; Jun 9th, 2009 at 10:37 am.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 5
Reputation: msnmnk is an unknown quantity at this point 
Solved Threads: 0
msnmnk msnmnk is offline Offline
Newbie Poster

Re: How we can upload a text file or word file using php Code???

 
0
  #5
Jun 9th, 2009
yes their is the same way to like upload images as well upload file on the server you have to get the properties of the file
  1. list($width, $height, $type, $attr) = getimagesize($_FILES['img']['tmp_name']);
<URL SNIPPED>xperts
Last edited by peter_budo; Jun 9th, 2009 at 10:39 am. Reason: Keep It On The Site - Do not manually post "fake" signatures in your posts. Instead, you may create a sitewide signature within the user control panel.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1130 | Replies: 4
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC