I have a webform for users of the site to insert information about theirself and then an image. However I don't want to save the image into the database as it will slow everything down...is there a way to save the image to my hardrive then create a link in the mySQL database to this image? How can I get the form to save the picture to my hardrive in the first place...thanks.

I have a webform for users of the site to insert information about theirself and then an image. However I don't want to save the image into the database as it will slow everything down...is there a way to save the image to my hardrive then create a link in the mySQL database to this image? How can I get the form to save the picture to my hardrive in the first place...thanks.

If the username is going to be unique over the website, then you dont even need to store the file names/image names to the database.
You can simply upload the user entered files to your hard drive in some directory named 'profile_pictures' with their user names and then fetch again by searching with the user name.

$uploads_dir = '/profile_pictures';
foreach ($_FILES["pictures"]["error"] as $key => $error) {
    if ($error == UPLOAD_ERR_OK) {
        $tmp_name = $_FILES["pictures"]["tmp_name"][$key];
       // $name = $_FILES["pictures"]["name"][$key];
//user name from some text field or wherever you want from
$name = $_POST['txtfld_username'];
        move_uploaded_file($tmp_name, "$uploads_dir/$name");
    }
}

Or else the user names are not unique over the website, you can upload them to the same directory and even save their names to the database associated with their usernames or user_ids

CREATE TABLE `profile_images` (
  `img_id` bigint(1) NOT NULL AUTO_INCREMENT,
  `img_name` varchar(30) DEFAULT NULL,
  `user_id` bigint(1) NOT NULL,
  `entry_date` datetime DEFAULT NULL,
  PRIMARY KEY (`img_id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 COLLATE=utf8_bin

or simply in the usermaster table too -

CREATE TABLE `usermaster` (
  `user_id` bigint(1) NOT NULL AUTO_INCREMENT,
  `name` varchar(30) DEFAULT NULL,
  `dob`  datetime,
  `country`  varchar(30) DEFAULT NULL,
   `profile_img` varchar(30) DEFAULT NULL,
  `entry_date` datetime DEFAULT NULL,
  PRIMARY KEY (`img_id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 COLLATE=utf8_bin
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.