help in upload file coding

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dakkonz
Forum Commoner
Posts: 69
Joined: Sat Dec 27, 2003 2:55 am
Location: Asia

help in upload file coding

Post by dakkonz »

Code: Select all

// Create the file name.
		$extension = explode ('.', $_FILESї'upload']ї'name']);
		$filename = $ref . '.' . $extensionї1];
	        	
		// Move the file over.
		if (move_uploaded_file($_FILESї'upload']ї'tmp_name'], "/home/server/public_html/trial/images/")) {
		
	      //increase the number of songs uploaded	
	        $numupload = $numupload + 1;
		    $query = "UPDATE user SET numupload='$numupload' WHERE useracc={$_SESSIONї'useracc']}";		
			$result = @mysql_query ($query); // Run the query.
			

			echo '<p>The file has been uploaded!</p>';
			exit();
		&#125; else &#123;
			echo '<p><font color="red">The file could not be moved.</font></p>';
			exit();

		&#125;
is there anything wrong with this upload code??
coz when i run it, i get an error message like this
"
Warning: move_uploaded_file(/home/server/public_html/trial/images/): failed to open stream: Is a directory in /home/server/public_html/trial/uploadsong.php on line 61

Warning: move_uploaded_file(): Unable to move '/tmp/phpavgk3i' to '/home/server/public_html/trial/images/' in /home/server/public_html/trial/uploadsong.php on line 61 "
can someone help me??
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

if your using windows and apache then you have to use $_SERVER['DOCUMENT_ROOT']....
try somehitng like:

Code: Select all

$directory = $_SERVER['DOCUMENT_ROOT'] . "/home/server/public_html/trial/images/";

 if (move_uploaded_file($_FILES['upload']['tmp_name'], $directory))
you may also have to to do that with the original file
dakkonz
Forum Commoner
Posts: 69
Joined: Sat Dec 27, 2003 2:55 am
Location: Asia

Post by dakkonz »

sorry to bother u but the same error message still comes out... is it something to do with my server setting???? my server is with nocster and i am using cpanel... i read somewhere that there is a file called php.ini for us to change the settings... but i cannot find it anywhere...Please Help
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

have you tried [php_man]chmod[/php_man]? you will need to set it to 0777 on the dir you are uploading too.
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

And also, does the dir exist? Thats always important :D
Post Reply