Home Answers Viewqa PHP How to change uploaded file root path ?

 
 


Shreepathi
How to change uploaded file root path ?
0 Answer(s)      7 months ago
Posted in : PHP

I have file upload php script. File upload working is good. But I can't find where saving that file. I think the files saving in mysql directory. How to change directory to my desired path ? like "uploads/"

upload.php script :

if(isset($POST['upload']) && $FILES['userfile']['size'] > 0) { $fileName = $_FILES['userfile']['name']; $tmpName = $FILES['userfile']['tmpname']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type'];

$fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp);

if(!getmagicquotes_gpc()) { $fileName = addslashes($fileName); }

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

$query = "INSERT INTO upload (name, size, type, content ) ". "VALUES ('$fileName', '$fileSize', '$fileType', '$content')";

mysql_query($query) or die('Error, query failed'); include 'library/closedb.php';

echo "
File $fileName uploaded
"; } ?>

View Answers









Related Pages:

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.