I have this code on my index.php page where i want the image to show; index.php and i have this where im trying to upload the image from; cms-events.php At the moment its working perfectly, and the file is uploading to my ftp server under /files folder but the image is not displaying on my index.php page? When i than go to the database to check all fields have been entered apart from the image field? is this why? does it also need to go the database before it can be viewed on the index.php page? or do i have to add an extra line of code for the image to display on the index.php page...
Change: $image = $_POST['image']; PHP: To: $image = $_FILES['imagefile']['name']; PHP: Also, the code for uploading file should be combined with the PHP code for collating POST data for SQL query. One last thing: if(isset( $Submit )) PHP: That should never be used as it relies on register_globals. Even if you are not distributing scripts, it is a good habit to use the proper method, in this case: $_POST['Submit']
if ($_FILES['imagefile']['type'] == "image/jpg" || $_FILES['imagefile']['type'] == "image/jpeg"){ //<--- Note the type (check the change below and post the error) Code (markup): note that $_FILES['imagefile']['type'] is sent by the browser you should not use this to validate the file type, to correctly validate look in to mime_content_type (deprecated) PECL extension Fileinfo or you can use something like this (from php.net documentation) if ( ! function_exists ( 'mime_content_type ' ) ) { function mime_content_type ( $f ) { return trim ( exec ('file -bi ' . escapeshellarg ( $f ) ) ) ; } } Code (markup):