HTML2011. 5. 16. 15:37

Twitter API  : http://dev.twitter.com/doc

Twitter API 사용하기 위해 oauth 절차


$connect = mysql_connect("localhost", "DB 아이디", "DB 비밀번호") or die(mysql_error());

mysql_select_db("선택할 DB") or die(mysql_error());

$result = mysql_fetch_array(mysql_query("select * from `twt_oauth`")); //db에서 값 array로 불러 오기


session_start();

require_once('twitteroauth/twitteroauth.php');

require_once('config.php');



$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $result['oauth_token'], $result['oauth_token_secret']) or die(mysql_error());  //oauth 설정 완료


//이제 여기서 Twitter API 사용 하면 됨.

$connection -> post('statuses/update', array('status' => $msg));

$user_timeline = $connection -> get('statuses/user_timeline');
//.....etc



http://www.google.co.kr/url?q=http://kldp.org/node/46239&sa=U&ei=WpCATdiTHo30vQPx-OzTBw&ved=0CB0QFjAIOBQ&usg=AFQjCNFVgKl9vy3w2lztZQz6UThM8tldDQ



계속 똑같은 질문을 도배를 합니다.

PHP 소스중에서
move_uploaded_file($_FILES["userfile"]["tmp_name"][$i],$_FILES["userfile"]["name"][$i]);

보면
$_FILES["userfile"]["tmp_name"] [$i]<-- 이부분은 /tmp 디렉토리에 임시저장 한다고 하내여.

그러면
$_FILES["userfile"]["name"][$i] <-- 이부분은 어느 폴드에 저장이 되는건가여..
이부분은 제가 따로 지정하는곳이 있는지 알고싶습니다.

계속 해결책을 못찾고 일주일을 넘게 짜증만 내고 있내여
쩝 ~~
별것도 안닌것 같은데 은근히 애를 먹이내여!



데이타가 업로드 되는 순간에는 /tmp 디렉토리에 저장 됩니다. 하지만 업로드가 완료되면 지정된 디렉토리 or 파일($_FILES["userfile"]["name"][$i]) 에 저장이 되겠죠.

echo 등으로 화면에 직접 $_FILES["userfile"]["name"][$i] 부분을 찍어 보시죠.



네 근데 제가 알고자 했던 것은
$_FILES["userfile"]["name"][$i] 지정된 디렉토리 or 파일이라는부분을 어디에서 설정을 해줘야 하는 질문이였습니다.
쩝 ~~
계속 삽질만 하내여 !!

Linux 를 배워봅시다.

Chapter 3. Handling file uploads

--중략---

$_FILES['userfile']['name']
The original name of the file on the client machine.

$_FILES['userfile']['type']
The mime type of the file, if the browser provided this information. An example would be "image/gif".

$_FILES['userfile']['size']
The size, in bytes, of the uploaded file.

$_FILES['userfile']['tmp_name']
The temporary filename of the file in which the uploaded file was stored on the server.

$_FILES['userfile']['error']
The error code associated with this file upload. ['error'] was added in PHP 4.2.0

--중략 --

Quote:

bool move_uploaded_file ( string filename, string destination )

$_FILES 안에는 POST로 넘어온 파일 정보가 있는대,
HTML에서 input type="file" tag의 name 속성이 첫번째 배열의 키가 되고, 두번째는 name, type, size, tmp_name, error 의 키가 있습니다. 각 키에 들어있는 값은
name은 클라이언트에서 보낸 파일의 이름,
type은 파일의 mime type,
size는 파일의 크기,
tmp_name은 파일이 넘어올때 PHP가 자동으로 받은후 /tmp 와 같은 미리 설정되어 있는 디렉토리로 임시 파일을 만들어 놓는대, 그 파일의 이름 입니다. ( /tmp/sd3w12412 같은식이겠죠..)
error는 파일이 넘어오다가 에러가 발생했을 경우 에러 코드가 들어갑니다.

move_uploaded_file은 첫번째 argument로 임시로 받아진 파일의 path를 받습니다. 두번째 argument로 이동할 곳의 path를 받습니다.

그래서 첫번째엔 tmp_name의 값이 가고,
두번째에 "옮기고 싶은 path"+"바꿀 파일 이름" 을 넣으면
"path/파일 이름"으로 이동 되겠죠.

이때 파일 이름을 _FILE의 name 값으로 주는게 보통인지라 위에서 처럼 되있겠죠.

이전에 질문하신 게시물들을 잠시 봤는대, 제가 보기엔
/tmp가 문제가 아니라 파일을 이동 시킬곳의 문제인거 같습니다.




출처 : 1305527810100000
Posted by 아이맥스