rondog Posted October 13, 2008 Share Posted October 13, 2008 I cant seem to get the files pushed up to the server through my form. My folder permissions are 755 for the mp3s and thumbnails folder. It is returning it is moving them successfully yet I do not see them. if(isset($_POST['add'])) { $lastPosition = mysql_query("SELECT position from $table ORDER BY position DESC LIMIT 1") or die(mysql_error()); $row = mysql_fetch_array($lastPosition); $newPosition = (int)$row['position'] + 1; $title = addslashes($_POST['title']); $thumbnail = $_FILES['thumbnail']['name']; $mp3 = $_FILES['mp3']['name']; $thumbnailPathUL = "../../".$thumbnailPath; $mp3PathUL = "../../".$mp3Path; $move1 = move_uploaded_file($_FILES['thumbnail']['tmp_name'], $thumbnailPathUL); $move2 = move_uploaded_file($_FILES['mp3']['tmp_name'], $mp3PathUL); if($move1 && $move2) { $sql = mysql_query("INSERT INTO $table (position,title,src,thumbnail,type) VALUES ('$newPosition','$title','$mp3Path$mp3','$thumbnailPath$thumbnail','mp3')") or die(mysql_error()); $status = "MP3 Successfully added!"; } } Link to comment https://forums.phpfreaks.com/topic/128290-solved-help-with-move_uploaded_file/ Share on other sites More sharing options...
trq Posted October 13, 2008 Share Posted October 13, 2008 755 will not give the Apache user write permissions to the directories. Link to comment https://forums.phpfreaks.com/topic/128290-solved-help-with-move_uploaded_file/#findComment-664540 Share on other sites More sharing options...
rondog Posted October 13, 2008 Author Share Posted October 13, 2008 So does it HAVE to be 777? Link to comment https://forums.phpfreaks.com/topic/128290-solved-help-with-move_uploaded_file/#findComment-664547 Share on other sites More sharing options...
rondog Posted October 14, 2008 Author Share Posted October 14, 2008 well I changed the dirs to 777 and it still doesnt work Link to comment https://forums.phpfreaks.com/topic/128290-solved-help-with-move_uploaded_file/#findComment-664550 Share on other sites More sharing options...
trq Posted October 14, 2008 Share Posted October 14, 2008 Where is $thumbnailPath defined? Link to comment https://forums.phpfreaks.com/topic/128290-solved-help-with-move_uploaded_file/#findComment-664559 Share on other sites More sharing options...
rondog Posted October 14, 2008 Author Share Posted October 14, 2008 it is defined in a file called config.php located at mediamanager/config.php and they are just this: $thumbnailPath = "thumbnails"; $mp3Path = "mp3s"; sooo esentially it is: '../../thumbnails' and '../../mp3s' The reason I have two up levels is because my actual form is in mediamanager/inc/mp3.php Link to comment https://forums.phpfreaks.com/topic/128290-solved-help-with-move_uploaded_file/#findComment-664562 Share on other sites More sharing options...
rondog Posted October 14, 2008 Author Share Posted October 14, 2008 any ideas? Link to comment https://forums.phpfreaks.com/topic/128290-solved-help-with-move_uploaded_file/#findComment-664596 Share on other sites More sharing options...
rondog Posted October 14, 2008 Author Share Posted October 14, 2008 Can anybody see what the problem is?? My paths are correct in relation to the location of the form. I am even getting a success message yet no files are being put into the folder. My form is at: mediamanager/inc/mp3.php I am uploading to: thumbnails (../../thumbnails) and mp3s (../../mp3s) both folders have 777 permissions... Link to comment https://forums.phpfreaks.com/topic/128290-solved-help-with-move_uploaded_file/#findComment-664714 Share on other sites More sharing options...
rondog Posted October 14, 2008 Author Share Posted October 14, 2008 alright my new topic got deleted...I guess I can try with my 4th reply with no help in this thread. I've tried directory "../thumbnails" & "../mp3s" as well as my above post. They both have the same results. Link to comment https://forums.phpfreaks.com/topic/128290-solved-help-with-move_uploaded_file/#findComment-665168 Share on other sites More sharing options...
MadTechie Posted October 14, 2008 Share Posted October 14, 2008 try this update $thumbnailPathUL = dirname(__FILE__)."../../".$thumbnailPath; $mp3PathUL = dirname(__FILE__)."../../".$mp3Path; Link to comment https://forums.phpfreaks.com/topic/128290-solved-help-with-move_uploaded_file/#findComment-665190 Share on other sites More sharing options...
rondog Posted October 14, 2008 Author Share Posted October 14, 2008 I am getting these errors when I try what you gave me: Warning: move_uploaded_file(/homepages/26/d220262095/htdocs/flashden/mp3player/mediamanager/inc../thumbnails) [function.move-uploaded-file]: failed to open stream: No such file or directory in /homepages/26/d220262095/htdocs/flashden/mp3player/mediamanager/inc/mp3.php on line 15 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpNxqxD9' to '/homepages/26/d220262095/htdocs/flashden/mp3player/mediamanager/inc../thumbnails' in /homepages/26/d220262095/htdocs/flashden/mp3player/mediamanager/inc/mp3.php on line 15 Warning: move_uploaded_file(/homepages/26/d220262095/htdocs/flashden/mp3player/mediamanager/inc../mp3s) [function.move-uploaded-file]: failed to open stream: No such file or directory in /homepages/26/d220262095/htdocs/flashden/mp3player/mediamanager/inc/mp3.php on line 16 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpXGK7Vr' to '/homepages/26/d220262095/htdocs/flashden/mp3player/mediamanager/inc../mp3s' in /homepages/26/d220262095/htdocs/flashden/mp3player/mediamanager/inc/mp3.php on line 16 I changed it from ../../ to just ../ because on the mp3.php is just an include of manager.php so I really only need to go up one directory. Link to comment https://forums.phpfreaks.com/topic/128290-solved-help-with-move_uploaded_file/#findComment-665198 Share on other sites More sharing options...
MadTechie Posted October 14, 2008 Share Posted October 14, 2008 for the path /homepages/26/d220262095/htdocs/flashden/mp3player/mediamanager/thumbnails use $thumbnailPathUL = dirname(__FILE__)."/../".$thumbnailPath; $mp3PathUL = dirname(__FILE__)."/../".$mp3Path; start and end with /'s Link to comment https://forums.phpfreaks.com/topic/128290-solved-help-with-move_uploaded_file/#findComment-665203 Share on other sites More sharing options...
rondog Posted October 14, 2008 Author Share Posted October 14, 2008 ok the error went away. It still didn't upload the files though and I actually need to get to: /homepages/26/d220262095/htdocs/flashden/mp3player/thumbnails My form exists on: /homepages/26/d220262095/htdocs/flashden/mp3player/mediamanager/manage.php (manage.php includes inc/mp3.php which is the actual form) EDIT:: I just found two files in my mediamanager folder called 'thumbnails' and 'mp3s'..they dont have extensions though. These appear to be the files except they are the wrong names and are in the wrong folder Link to comment https://forums.phpfreaks.com/topic/128290-solved-help-with-move_uploaded_file/#findComment-665206 Share on other sites More sharing options...
rondog Posted October 14, 2008 Author Share Posted October 14, 2008 hah! I figured it out! I wasnt adding the filename to the path! HEre is the working code: if(isset($_POST['add'])) { $lastPosition = mysql_query("SELECT position from $table ORDER BY position DESC LIMIT 1") or die(mysql_error()); $row = mysql_fetch_array($lastPosition); $newPosition = (int)$row['position'] + 1; $title = addslashes($_POST['title']); $thumbnail = strtolower( str_replace( " ", "_", basename( $_FILES['thumbnail']['name'] ) ) ); $mp3 = strtolower( str_replace( " ", "_", basename( $_FILES['mp3']['name'] ) ) ); $thumbnailPathUL = "../thumbnails/".$thumbnail; $mp3PathUL = "../mp3s/".$mp3; $move1 = move_uploaded_file($_FILES['thumbnail']['tmp_name'], $thumbnailPathUL); $move2 = move_uploaded_file($_FILES['mp3']['tmp_name'], $mp3PathUL); if($move1 && $move2) { $sql = mysql_query("INSERT INTO $table (position,title,src,thumbnail,type) VALUES ('$newPosition','$title','$mp3Path$mp3','$thumbnailPath$thumbnail','mp3')") or die(mysql_error()); $status = "MP3 Successfully added!"; } Link to comment https://forums.phpfreaks.com/topic/128290-solved-help-with-move_uploaded_file/#findComment-665218 Share on other sites More sharing options...
MadTechie Posted October 14, 2008 Share Posted October 14, 2008 EDIT: lol close to mine for the path /homepages/26/d220262095/htdocs/flashden/mp3player/thumbnails use $thumbnailPathUL = dirname(__FILE__)."/../../".$thumbnailPath; $mp3PathUL = dirname(__FILE__)."/../../".$mp3Path; //ALSO $move1 = move_uploaded_file($_FILES['thumbnail']['tmp_name'], $thumbnailPathUL.."/$thumbnail"); $move2 = move_uploaded_file($_FILES['mp3']['tmp_name'], $mp3PathUL."/$mp3"); Link to comment https://forums.phpfreaks.com/topic/128290-solved-help-with-move_uploaded_file/#findComment-665222 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.