Re: Problem of Upload media file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



here is the complete code, so you can check it
================================================

<?

$uploadDir = 'www/media/';


if(isset($_POST['upload']))
{
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];

// the files will be saved in filePath
$filePath = $uploadDir . $fileName;

$result = move_uploaded_file($tmpName, $filePath);
if (!$result) {
echo "Error uploading file";
exit;
}

include 'library/config.php';
include 'library/opendb.php';

if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}

$query = "INSERT INTO upload2 (name, size, type, path ) ".
"VALUES ('$fileName', '$fileSize', '$fileType', '$filePath')";

mysql_query($query) or die('Error, query failed : ' . mysql_error());

include 'library/closedb.php';

echo "<br>File uploaded<br>";
}
?>
================================================
end
 On 11/17/05, Micah Stevens <micah@xxxxxxxxxxxxxxxxxx> wrote:
>
>
> Keep in mind you're referring to a filesystem path, and a relative one to
> boot, so what you're telling php is, that your upload directory is:
>
> /home/somally/public_html/music/music/media/
>
> Which doesn't sound like what you intend.
>
> Also don't trust the php line numbers if you have significant whitespace
> in
> your code, sometimes it can get screwey. Look for your move_uploaded_file
> statement.
>
> -Micah
>
>
> On Thursday 17 November 2005 8:58 am, Mohamed Yusuf wrote:
> > I am trying to upload music file to server using php and saving file
> path
> > to the MySql, But I am getting this error message "*Warning*:
> > move_uploaded_file(music/media/): failed to open stream: No such file or
> > directory in */home/somally/public_html/music/upload2.php* on line
> *36*".
> > line 36 is reference of this code *$uploadDir = 'www/music/media/';*
> > so what am I missing?, any help?
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux