<html>
<body>
<form method="post" enctype="multipart/form-data">
Select file to upload:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload File" name="submit">
</form>
<?php
if(isset($_POST['submit']))
{
if($con = mysqli_connect('localhost','root','','mooc'))
{
$filetemp = $_FILES['fileToUpload']['tmp_name'];
$filename = $_FILES['fileToUpload']['name'];
$filetype = $_FILES['fileToUpload']['type'];
$filepath = "csvfiles/".$filename;
$m=new MongoDB\Driver\Manager();
//
// echo "Connected to database successfully.";
// $db=$m->test;
// echo "database selected";
//echo "enter";
//echo shell_exec("python C:/xampp/Xampp/htdocs/csvseparator.py 2>&1");
//echo "left";
$ip = $_SERVER['REMOTE_ADDR'];
$file1=explode(".",$filename);
$ext=$file1[1];
$allowed=array("bson");
if(in_array($ext,$allowed))
{
move_uploaded_file($filetemp,$filepath);
$query = "INSERT INTO csv(name,path,type,ip) VALUES('$filename','$filepath','$filetype','$ip')";
$ros = mysqli_query($con,$query);
echo "file uploaded";
//echo shell_exec("mongorestore -d admin -c contents /opt/lampp/htdocs/project/production/csvfiles/contents.bson --port 27017 -u 'admin' -p 'admin123' --authenticationDatabase 'admin' 2>&1");
//echo shell_exec("mongoexport --db admin --collection contents --fields _id,_type,abuse_flaggers,anonymous,anonymous_to_peers,at_position_list,author_id,author_username,body,closed,comment_count,comment_thread,commentable_id,course_id,created_at,endorsed,historical_abuse,last_activity_at,parent_id,parents_id,sk,thread_type,title,updated_at,visible,votes --out /opt/lampp/htdocs/project/production/csvfiles/out.csv --port 27017 -u 'admin' -p 'admin123' --authenticationDatabase 'admin' 2>&1");
}
else
{
echo "Upload only Bson file";
echo "<br />";
echo '<a href="upload1.php">Click here</a> to go back and try again';
}
}
}
?>
</body>
</html>
I am using Ubuntu 16.04
These are my shell commands :
mongorestore -d admin -c contents /opt/lampp/htdocs/project/production/csvfiles/contents.bson --port 27017 -u 'admin' -p 'admin123' --authenticationDatabase 'admin'
mongoexport --db admin --collection contents --fields _id,_type,abuse_flaggers,anonymous,anonymous_to_peers,at_position_list,author_id,author_username,body,closed,comment_count,comment_thread,commentable_id,course_id,created_at,endorsed,historical_abuse,last_activity_at,parent_id,parents_id,sk,thread_type,title,updated_at,visible,votes --out /opt/lampp/htdocs/project/production/csvfiles/out.csv --port 27017 -u 'admin' -p 'admin123' --authenticationDatabase 'admin'
How do i get over this issue?
When I use 2>&1
along with the commands, it gives me an error as:
mongorestore: relocation error: mongorestore: symbol X509_NAME_free, version OPENSSL_1.0.0 not defined in file libcrypto.so.1.0.0 with link time reference
and
mongoexport: relocation error: mongoexport: symbol X509_NAME_free, version OPENSSL_1.0.0 not defined in file libcrypto.so.1.0.0 with link time reference
P.S: When I run the two mongo commands from my cmd window, I get the output as expected.
The commands read a bson file and output its content into a csv file and creates a new csv file. I have attached my php file. Please help me!
</div>