Page 1 of 1

help in upload file coding

Posted: Tue Feb 10, 2004 11:13 pm
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??

Posted: Tue Feb 10, 2004 11:24 pm
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

Posted: Wed Feb 11, 2004 1:10 pm
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

Posted: Wed Feb 11, 2004 1:25 pm
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.

Posted: Wed Feb 11, 2004 3:37 pm
by DuFF
And also, does the dir exist? Thats always important :D