prak Posted April 18, 2017 Share Posted April 18, 2017 Hello, I'm trying to upload an image to a folder called uploads in my module's root. I have been able to accomplish this with the shop installed on my machine but I cannot upload the desired image to the remote shop. Here is my code: connector.php, to use curl to send the image to the upload.php file: require_once(dirname(__FILE__).'../../../config/config.inc.php'); require_once(dirname(__FILE__).'../../../init.php'); if (isset($_FILES['userfile']['tmp_name'])) { $ch = curl_init(); $cfile = new CURLFile($_FILES['userfile']['tmp_name'],$_FILES['userfile']['type'],$_FILES['userfile']['name']); $data = array('image'=>$cfile); curl_setopt($ch,CURLOPT_URL,_PS_BASE_URL_."/modules/customizeproducts/upload.php"); curl_setopt($ch,CURLOPT_POST,true); curl_setopt($ch,CURLOPT_POSTFIELDS,$data); $resp = curl_exec($ch); if($resp == true){ echo "success"; } else{ echo curl_error($ch); } } the upload.php file: if (isset($_FILES['image']['tmp_name'])) { error_reporting(E_ALL); $uploaddir = 'uploads/'; $uploadfile = $uploaddir . basename($_FILES['image']['name']); if (move_uploaded_file($_FILES['image']['tmp_name'], $uploadfile)) { $data = array($uploadfile,$uploaddir); echo json_encode($data); } else { echo "Possible file upload attack!\n"; print_r($_FILES); } } This is the console.log "Possible file upload attack!Array( [image] => Array ( [name] => shoex.jpeg [type] => image/jpeg [tmp_name] => /tmp/phpkwpWFu [error] => 0 => 8373 )) " I'm a newbie to php and curl Help would be greatly appreciated! Link to comment Share on other sites More sharing options...
vividusdesigns Posted April 18, 2017 Share Posted April 18, 2017 It may be folder permission issue as its works fine on your local machine. did you check if you have write permission to the folder your trying to upload. Thanks & regards 1 Link to comment Share on other sites More sharing options...
prak Posted April 18, 2017 Author Share Posted April 18, 2017 Thanks for the reply vividusdesigns! That was the case. I was overthinking this whole thing instead of just checking folder permissions,lol! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now