1

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

5
Contributors
4
Replies
12
Views
7 Years
Discussion Span
Last Post by msnmnk
1

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

1

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");
}
}
1

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

list($width, $height, $type, $attr) = getimagesize($_FILES['img']['tmp_name']);

<URL SNIPPED>xperts

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.