svgmx5 Posted November 16, 2009 Share Posted November 16, 2009 I've got this script, in which i want to insert the image path into my database. The image is saved into a folder on the server, then the location should be updated into the database. I'm not getting any errors so far, the file is just not getting uploaded into the folder or database. I hope some can give a hand Thank Code is below <?php if(isset($_POST['update']) && !empty($_POST['update'])){ //Determine the path to which we want to save this file $thumbPath = "images/userImages/"; $thumbPath = $thumbPath . basename($_FILES['profileImage']['name']); //Attempt to move the uploaded file to it's new place if(move_uploaded_file($_FILES['profileImage']['tmp_name'], $thumbPath)){ $sql = "UPDATE tutorProfiles SET img='$thumbPath ' WHERE tutor='$tutorID'"; $run = mysql_query($sql) or die(mysql_error()); $msg = ' <p>profile Image updated Succesfully!</p> '; }else{ $msg = ' <p>There was an error updating your profile image</p> '; } } ?> I've used this code in the past to insert images into a folder, but to insert the image location into the database. Link to comment https://forums.phpfreaks.com/topic/181668-inserting-an-image-path-into-the-database/ Share on other sites More sharing options...
play_ Posted November 16, 2009 Share Posted November 16, 2009 The reason it's not being inserted/updated in the database, is because if inside an IF and the condition is returning false. if(move_uploaded_file($_FILES['profileImage']['tmp_name'], $thumbPath)){ the image isn't being moved, so the query inside this if block won't execute. So what you have to do is figure out why the image isn't being moved. Most likely folder permission issues. Link to comment https://forums.phpfreaks.com/topic/181668-inserting-an-image-path-into-the-database/#findComment-958374 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.