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

The same way you upload images you can upload other files.

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

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.