Jump to content

Recommended Posts

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

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

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...

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.

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

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!";
	}

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");

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.