svgmx5 Posted February 27, 2010 Share Posted February 27, 2010 How can i upload an image path to a sql Database? I know how can i insert the path of the image into the database, but how can i upload the image at the same time? Quote Link to comment https://forums.phpfreaks.com/topic/193548-quick-question-regarding-uploading-image-paths-to-an-sql-db/ Share on other sites More sharing options...
harristweed Posted February 27, 2010 Share Posted February 27, 2010 http://www.google.co.uk/search?hl=en&source=hp&q=php+image+upload+script&meta=&aq=0&oq=php+image+upload Quote Link to comment https://forums.phpfreaks.com/topic/193548-quick-question-regarding-uploading-image-paths-to-an-sql-db/#findComment-1018881 Share on other sites More sharing options...
inversesoft123 Posted February 27, 2010 Share Posted February 27, 2010 Upload Image use HTML upload. then copy and unlink image. copy($HTTP_POST_FILES['uploadedfile']['tmp_name'],"/home/domainfolder/public_html/files/location/$userid/".$hashedfilename); unlink($HTTP_POST_FILES['uploadedfile']['tmp_name']); Then save this filename in database mysql_query("INSERT INTO tableprefix_uploads SET uid='".$uid."', type='filetype', cdate='".$todate."', name='".$filenamename."', hashedname='".$hashedfilename."'"); if you need full script send me request. Quote Link to comment https://forums.phpfreaks.com/topic/193548-quick-question-regarding-uploading-image-paths-to-an-sql-db/#findComment-1018882 Share on other sites More sharing options...
inversesoft123 Posted February 27, 2010 Share Posted February 27, 2010 But beware designing uploading script as someone can upload Trojans and harmful virus related files on your server. You must strictly check that uploaded file is a valid image file or not. You can check it by opening file and reading first few characters of file Somthing Like $f = @fopen($_FILES['uploadedfile']['tmp_name'],'r'); $s = @fread($f,4); @fclose($f); if($s != "ÿØÿà"){ echo “Invelid File”; } Quote Link to comment https://forums.phpfreaks.com/topic/193548-quick-question-regarding-uploading-image-paths-to-an-sql-db/#findComment-1018885 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.