Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Attach images (like hotmail)

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Attach images (like hotmail)

Postby AaaDee » Thu Jul 04, 2002 1:53 am

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.
User avatar
AaaDee
New php-forum User
New php-forum User
 
Posts: 25
Joined: Mon Jun 24, 2002 1:10 am
Location: Huddersfield

Postby Oleg Butuzov » Thu Jul 04, 2002 7:31 am

Hy Adam.



By the first we need a html form =)

Code: Select all
<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: Select all
<?


// 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: Select all
<?
echo("<img src=$link>");
?>



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

Regards. Pejone
Oleg Butuzov
Last Samuray
Last Samuray
 
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Re: Attach images (like hotmail)

Postby WiZARD » Fri Jul 05, 2002 1:05 am

AaaDee wrote: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...
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.