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."; } 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. 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? 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. :/ 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? 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.. 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.. Link to comment https://forums.phpfreaks.com/topic/254752-inserting-images-using-_files/#findComment-1307404 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.