I have a server apache and mysql at my friend's house, i can connect to both of them, but i want to upload pictures from my Macbook to my directory in the server (Ubuntu), i have some issues and tried many things but any of them worked, please help me thanks :)
The html form:
<html>
<head>
</head>
<body>
<form accept-charset="UTF-8" action="php.php" method="POST" enctype="multipart/form-data">
<input type="file" name="img"/>
<input type="submit"/>
</form>
</body>
</html>
The php :
<html>
<head> <meta charset="UTF-8"/> </head>
</html>
<?php
$bdd = new PDO('mysql:host=***.***.***.***;port:****;dbname=**********', '*******', '**********',array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
echo $_FILES['img']['name'];
$target1 = "/home/knight/";
$target = $target1 . basename( $_FILES['img']['name']);
if(move_uploaded_file($_FILES['img']['tmp_name'], $target))
{
//Tells you if its all ok
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";
}
else {
//Gives and error if its not
echo "Sorry, there was a problem uploading your file.";
}
?>