note 38979 added to features.file-upload

From: Date: Wed, 14 Jan 2004 00:49:14 +0000
Subject: note 38979 added to features.file-upload
Groups: php.notes 
Request: Send a blank email to php-notes+get-63482@lists.php.net to get a copy of this message
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'].")"; } } ---- Manual Page -- http://www.php.net/manual/en/features.file-upload.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+38979 Delete -- http://master.php.net/manage/user-notes.php?action=delete+38979&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+38979&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#63482) next »