Jump to content

Quick Question regarding uploading image paths to an sql DB


svgmx5

Recommended Posts

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. :)

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”;
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.