Tenaciousmug Posted January 10, 2012 Share Posted January 10, 2012 Ok, I have this working on another page from a long time ago, but it's not working right here: It gets past the if($num == 0) part, but when it's seeing if the files has been uploaded, it's not getting past that and it won't give me my error message too. So I have a feeling it's getting past it, but it's not uploading it into the software/ directory and not inserting it into the database. I get no errors in my error_log or my default errors I have set up under the variable, $message. $target_path = "software/"; $basename = strtolower(basename($_FILES['softwarePath']['name'])); $target_path = $target_path . $basename; $sql = "SELECT softwarePath FROM software WHERE softwarePath='$target_path'"; $result = mysqli_query($cxn, $sql) or die(mysqli_error()); $num = mysqli_num_rows($result); if($num == 0) { if(move_uploaded_file($_FILES['softwarePath']['tmp_name'], $target_path)) { $sql = "INSERT INTO software(softwareName,softwareType,softwareDesc,softwarePath,ITOnly) VALUES('$softwareName','$softwareType','$softwareDesc','$target_path','$ITOnly')"; mysqli_query($cxn,$sql) or die(mysqli_error()); header("Location: search_software.php"); } } else { $message = "There is already a file with that name."; } Quote Link to comment https://forums.phpfreaks.com/topic/254752-inserting-images-using-_files/ Share on other sites More sharing options...
Tenaciousmug Posted January 11, 2012 Author Share Posted January 11, 2012 Anyone have any help on this? I can't seem to find anything on Google. Quote Link to comment https://forums.phpfreaks.com/topic/254752-inserting-images-using-_files/#findComment-1306305 Share on other sites More sharing options...
scootstah Posted January 11, 2012 Share Posted January 11, 2012 What does $_FILES['softwarePath']['error'] give you? Quote Link to comment https://forums.phpfreaks.com/topic/254752-inserting-images-using-_files/#findComment-1306307 Share on other sites More sharing options...
Tenaciousmug Posted January 11, 2012 Author Share Posted January 11, 2012 Darn. I thought that would give me an error message, but it doesn't give me any error message in my error_log either. :/ Quote Link to comment https://forums.phpfreaks.com/topic/254752-inserting-images-using-_files/#findComment-1306327 Share on other sites More sharing options...
scootstah Posted January 11, 2012 Share Posted January 11, 2012 Is $target_path writable by the server? Quote Link to comment https://forums.phpfreaks.com/topic/254752-inserting-images-using-_files/#findComment-1306510 Share on other sites More sharing options...
Tenaciousmug Posted January 13, 2012 Author Share Posted January 13, 2012 Yeah you're right. It's only showing the target_path and not even the basename variable so it's obviously not grabbing it. Ok here is the HTML part for my file upload: <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Software Upload:<br /> <input name="softwarepath" type="file" /><br /> And the PHP: $target_path = "software/"; $basename = strtolower(basename($_FILES['softwarepath']['name'])); $target_path = $target_path . $basename; echo $target_path; It won't echo the target_path though.. Quote Link to comment https://forums.phpfreaks.com/topic/254752-inserting-images-using-_files/#findComment-1307245 Share on other sites More sharing options...
Tenaciousmug Posted January 13, 2012 Author Share Posted January 13, 2012 I've looked up many tutorials and still can't find an answer. D: I see this getting pushed down really far and just wanted to move it back up so maybe someone can still help me? It's only echoing "software/". It's not echoing the file i uploaded, but I checked the "name" attribute in the form and the name it's pulling and they both are the same.. Quote Link to comment https://forums.phpfreaks.com/topic/254752-inserting-images-using-_files/#findComment-1307404 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.