2015-02-23 62 views
0
<? if(isset($_POST["submit"])) 
{ 

$f_name = $_FILES["filetoupload"]["name"]; 
$f_tmp = $_FILES["filetoupload"]["tmp_name"]; 
$store = "uploads/".$f_name; 

if(move_uploaded_file($f_tmp,$store)) 
    echo "file uploaded successfully"; 
    echo"<br>"; 
} 

$line = fgets($f_open); 
echo $line; 
$url = "http://maps.googleapis.com/maps/api/geocode/json?address="; 
$furl ="$url"."$line"; 
echo "$furl"; 
$ch = curl_init("$furl"); 
$fp = fopen("example4.txt","w"); 

curl_setopt($ch, CURLOPT_PROXY, '10.10.80.11:3128'); 
curl_setopt($ch, CURLOPT_FILE, $fp); 
curl_setopt($ch, CURLOPT_HEADER, 0); 

curl_exec($ch); 
curl_close($ch); 
fclose($fp); 


echo $json['results'][0]['address_components'][0]['types'][0]; 
echo $json['results'][0]['address_components'][0]['types'][1]; 

$data=json_decode($jsondata); 
$address=$data->results[0]->address_components; 
?> 

波夫提到的程序,要上傳的文件中讀取值,並將其發送到URL地址

我試圖從上傳的文件檢索由線值線和連接具有URL檢索值,

但我得到了錯誤的短信..

注意:試圖讓非對象的財產 C:\ XAMPP \ htdocs中\ phpprog \ upload_file_add.php上線50 ...

哪裏是我的錯誤與說明...

+2

u能PLZ讓我們知道哪一行是在文件upload_file_add你的行數50 .PHP? – 2015-02-23 08:06:47

+0

'$ f_open'從哪裏來? – julekgwa 2015-02-23 10:08:16

+0

嘗試下面的代碼 – julekgwa 2015-02-23 12:22:25

回答

0

我想你需要檢查你的$ jsondata變量是使用json_decode之前有效。這可能是您在$ data中接收到空值,因此當您嘗試訪問其屬性時,它不再是對象。 在json_decode($ jsondata)之後使用var_dump($ data)來驗證您正在接收您期望的內容。

0

你給我們的代碼有變量,我們不知道它們來自哪裏,比如你的$f_open$json。如果不使用fopen()打開文件,則不能使用fgets()

$f_name = $_FILES["filetoupload"]["name"]; 
$f_tmp = $_FILES["filetoupload"]["tmp_name"]; 
$store = "uploads/".$f_name; 

if(move_uploaded_file($f_tmp,$store)){ 
    echo "file uploaded successfully"; 
    echo"<br>"; 
} 
$f_open = fopen($store,"r"); 
$line = fgets($f_open); 
echo $line; 
$url = "http://maps.googleapis.com/maps/api/geocode/json?address="; 
$furl ="$url"."$line"; 
echo "$furl"; 

讀取其中包含一個文本文件reading_files_with_PHP 上面的代碼顯示

reading_files_with_PHP
http://maps.googleapis.com/maps/api/geocode/json?address=reading_files_with_PHP

相關問題