HELLO
I have this php script that uploads photos to the server and store the file name to a database.
I have tested the script in to my computer and the script is working.
I upload the php script to the server and the script is not working correctly. It stores the file name to the database but it can’t upload the file to the server.
The error message:
Warning: move_uploaded_file([url]http://www.****.com/prime/profile-photos/aspa[/url] fotoo.jpg): failed to open stream: HTTP wrapper does not support writeable connections. in /home/main/public_html/prime/photos_update.php on line 161
Warning: move_uploaded_file(): Unable to move '/var/tmp/phpqhN7hc' to 'http://www.****.com/prime/profile-photos/aspa fotoo.jpg' in /home/main/public_html/prime/photos_update.php on line 161
There was an error uploading the file, please try again!
PLEASE HELP !!!!
php script:
$target_path = "http://www.****.com/prime/profile-photos/";
$file_check = $target_path . $_FILES['uploadedfile']['name'];
$connection = mysql_connect($db_host, $db_user, $db_password) or die("error connecting");
mysql_select_db($db_name, $connection);
$query = "SELECT * from photos WHERE path like '%".$file_check."%'";
$result = mysql_query($query, $connection);
$num_result = mysql_num_rows($result);
if ($num_result > 0) {
echo "This file name exist, rename the file and try again";
} else {
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
LINE 161 --------- if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
$file = $_FILES['uploadedfile']['name'];
$path = 'profile-photos/'.$file;
$connection = mysql_connect($db_host, $db_user, $db_password) or die("error connecting");
mysql_select_db($db_name, $connection);
$query = "INSERT INTO photos (autoID, path) VALUES (NULL, '$path')";
mysql_query($query, $connection) or die(mysql_error());
}