Re: Upload and PullPicture???
| From: | Matt Hedges | Date: | Wed, 14 Jan 2004 00:49:36 +0000 |
| Subject: | Re: Upload and PullPicture??? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-174499@lists.php.net to get a copy of this message | ||
I figured it out...
You can put everything in one file...
<form name="form1" method="post" action=""
enctype="multipart/form-data">
<input type="file" name="imagefile" size="20">
<input type="submit" name="Submit" value="Submit">
<?
if(isset( $Submit ))
{
if ($_FILES['imagefile']['type'] == "image/pjpeg"){
$extension=".jpg";
// define the base image dir
$base_img_dir = "images/";
// generate unique id for use in filename
$uniq = uniqid("");
// new file name
$filename = $base_img_dir.$uniq.$extension;
move_uploaded_file($_FILES["imagefile"]["tmp_name"], $filename)
or die ("Could not copy");
echo "";
echo "Name: ".$_FILES['imagefile']['name']."";
echo "Size: ".$_FILES['imagefile']['size']."";
echo "Type: ".$_FILES['imagefile']['type']."";
echo "Copy Done....";
}
else {
echo "";
echo "Could Not Copy, Wrong Filetype
(".$_FILES['imagefile']['name'].")";
}
}
....
and then whatever else you want it to do (be sure to include connecter to
MySQL database). thanks to everyone who helped, especially
http://www.evolt.org/article/Storage_and_re_use_of_images_using_PHP_GD_Part_1/20/27237/
"Matt Hedges" <matt@hedges.org> wrote in message
news:20040113211105.8406.qmail@pb1.pair.com...
> Hello... I'm trying to upload a picture along with other information.
>
> I have several fields to input, such as name, address, etc. (and I get
those
> to go to the MySQL database with no problem). But on the same page I want
> the user to be able to pick a picture of themself from their harddrive and
> upload it. The script must either enter the address of the uploaded
picture
> to MySQL so it will show up with the user's info., or rename it something
> like $id.ext.
>
>
> I know something like this needs to go in the html:
>
> <form enctype="multipart/form-data" action="_URL_"
> method="POST">
> <input type="hidden" name="MAX_FILE_SIZE" value="30000">
> Send this file: <input name="userfile" type="file">
> <input type="submit" value="Send File">
> </form>I'd like to just use one "submit" button that uploads everything
(the
> data to the database and the picture to my server).
>
> I've read the PHP manual but it's greek to this newbie... any help GREATLY
> appreciated....
>
>
> thanks,
> Matt