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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.