[ad_1]
I am trying to upload an Image to a directory hosted by Bluehost, using this code:
<?php
header("Access-Control-Allow-Origin: http://127.0.0.1:5500");
if ( 0 < $_FILES['file']['error'] ) {
echo 'Error: ' . $_FILES['file']['error'] . '<br>';
}
else {
move_uploaded_file($_FILES['file']['tmp_name'], 'https://example.com/UserUploads/'.$_FILES['file']['name']);
$location = 'https://example.com/UserUploads/'.$_FILES['file']['name'];
echo '<img src="'.$location.'" />';
}
?>
It has worked for two files but not for the rest I tried to upload.
I read that the location can’t include https://
, and I should use $_SERVER['DOCUMENT_ROOT']
but otherwise the url just sends me to google.
Using the above code I get
PHP Fatal error: require(): Failed opening required '/home3/example/public_html/wp-blog-header.php' (include_path=".:/opt/cpanel/ea-php74/root/usr/share/pear") in
and
PHP Warning: move_uploaded_file(https://example.com/UserUploads/20181013_COMM_gigsgreen033.jpg): failed to open stream: HTTP wrapper does not support writeable connections in
Any help greatly appreciated
[ad_2]