note 38979 deleted from features.file-upload by tomsommer

From: Date: Wed, 14 Jan 2004 08:23:50 +0000
Subject: note 38979 deleted from features.file-upload by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-63492@lists.php.net to get a copy of this message
Note Submitter: Hedges ---- I've had a lot of trouble uploading an image to be pulled from a database (which means you probably need to rename it)... I've found this is an easy way to do it: 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'].")"; } }

« previous php.notes (#63492) next »