I need your help with uploading an image file from google compute engine instance to google cloud storage. I have been able to move an image from a frontend form with php with the usual move_uploaded_file function but the real problem surfaces when I Try to copy that file to google cloud storage within php script using gsutil command. After quick debugging I found these results
**Tue Jan 01 04:45:12.491702 2019] [core:notice] [pid 8539] AH00094: Command line: '/usr/sbin/apache2'
sh: 1: /var/www/includes/multimediaStorage.sh/var/www/html/uploads/markii.jpg: not found
sh: 1: /var/www/includes/unloadUploads.sh/var/www/html/uploads/markii.jpg: not found
baraka_ben@igroup1us-xszd:/var/log/apache2$ cd /var/www/html/uploads/
baraka_ben@igroup1us-xszd:/var/www/html/uploads$ ls
markii.jpg
baraka_ben@igroup1us-xszd:/var/www/html/uploads$ ls -lh
total 4.0K
-rw-r--r-- 1 www-data www-data 3.0K Jan 1 04:50 markii.jpg
baraka_ben@igroup1us-xszd:/var/www/html/uploads$**
But again, if I try the same command within the shell console ssh environment it runs smoothly without any problem as shown hereunder
baraka_ben@igroup1us-xszd:/var/www/html/uploads$ gsutil cp markii.jpg gs://bucket/Folder/SubFolder
Copying file://markii.jpg [Content-Type=image/jpeg]...
/ [1 files][ 2.9 KiB/ 2.9 KiB]
Operation completed over 1 objects/2.9 KiB.
baraka_ben@igroup1us-xszd:/var/www/html/uploads$
nota bene the bucket name shown here is not the actual one and the multimediaStorage.sh script contains similar command syntax to what the above code has. Now I am stranded as I Tried to figure out the folder and file ownership and permissions rights by making the "www-data" user the owner of the folder /var/www/html/uploads but it does not seem to be of any help. May you please help me to get over this hurdle. Down here is my php script part related to this question
if (!empty($_FILES['picha']) && $_FILES['picha']['error'] == UPLOAD_ERR_OK) {
$tmpName = $_FILES['picha']['tmp_name'];
$name = basename($_FILES['picha']['name']);
$desnation="/var/www/html/uploads/$name";
$message=move_uploaded_file($tmpName,$desnation);
$repository=$desnation;
$destiny="gs://BucketName/Folder/Subfolder/";
$execution="/var/www/includes/multimediaStorage.sh";
$destination ='gs:BucketName/Folder/Subfolder/'."$name";
$combination="$repository $destiny";
exec($execution.''.$combination);
$clearence="/var/www/includes/unloadUploads.sh";
array_push($Patharray,$destination);
// unlink("/var/www/html/uploads/$filename");
exec($clearence.''.$repository);
}
Happy New Year 2019 and THANKS IN ADVANCE!