Attach images (like hotmail)

A

Anonymous

Guest
Hi, i am creating an intranet for my work. We are adding a news page where the user is given a form to fill out and is asked to fill them in and add an attachment.

I want to upload the attachments into a folder and add the name and directory the attatchment in.

Then on the next page it gives you a link saying the name of the upload and you can click on it to view it.

What we are wanting is exactly the same as what you do when you add an attatchment to a homail message.

Any help would be very much appreciated. :)
Thank you.
 
Hy Adam.



By the first we need a html form =)

Code:
<form enctype=multipart/form-data action=add_pic.php method=post>
Which file??? <input name=picture type=file>
Your name is .... <input  type=text name=username>
<input type=submit value="OK!">
</form>


that all for this time... =)

Next step. We will save a file into the folder.

Code:
<?


// so if have a file we will save him, but we must test is this file a picture or not

$userfile_name=$HTTP_POST_FILES['picture']['name'];
$userfile_size=$HTTP_POST_FILES['picture']['size'];
$userfile_type=$HTTP_POST_FILES['picture']['type']

if ($userfile_size > 524288000) { echo ("This file to big for saving at our server. Sorry!"); }
if ($userfile_type == "image/gif"  or  $userfile_type == "image/jpeg" or $userfile_type == "image/png") 
{
// In this case file is image and we are go to the dir where are pictures situated 

// create a dir 
$destination="/$username/"
mkdir ($destination, 0700); // I hope you want save pic into the $user - directory ...

$fd  =$destination;
$fd .=$$userfile_name;

if (file_exists($fd)) 
{
move_uploaded_file ($userfile_name, $destination);
copy($userfile_name);
echo("<a href=showpic.php?link=$fd>link</a>");
}

}

?>
and this file if you want to see your picture

Code:
<?
echo("<img src=$link>");
?>


There is can be a misstakes becouse i fell bad and can think truly.

Regards. Pejone
 
AaaDee said:
Hi, i am creating an intranet for my work. We are adding a news page where the user is given a form to fill out and is asked to fill them in and add an attachment.

I want to upload the attachments into a folder and add the name and directory the attatchment in.

Then on the next page it gives you a link saying the name of the upload and you can click on it to view it.

What we are wanting is exactly the same as what you do when you add an attatchment to a homail message.

Any help would be very much appreciated. :)
Thank you.

Hi!
Sorry but never use HOTMAIL.com and understand what you talking about...
 
Back
Top