파일전송 다시 질문드립니다. 정보
파일전송 다시 질문드립니다.본문
ㅜㅜ 하다하다 안되네요. 질문도 몇번 올렸는데요..
제가 잘 몰라서 그런지 잘 안되네요..
화일 두개에 들어갈 소스좀 부탁드립니다...
a.php 에 전송폼 b.php 에 완료화일좀 부탁드릴께요
input file <-- 을 이용해서요 전송을 하면... 같은 이름의 화일이 있더라도 무시하고
덮어씨워지면 되구요..
폴더는 g4_path/school/img <-- 이 폴더안에 전송되면 됩니다.
이와이면 어떤 화일을 입력하더라도 img1.jpg 로 변경되면 더 좋구요 ㅜㅜ
부탁드립니다...
댓글 전체
http://www.google.co.kr/search?sourceid=navclient&hl=ko&ie=UTF-8&rlz=1T4GFRI_koKR234KR235&q=php+%ed%8c%8c%ec%9d%bc+%ec%97%85%eb%a1%9c%eb%93%9c+%ec%86%8c%ec%8a%a4
구글에서 "php 파일 업로드 소스"로 검색해 보시면 참고할 소스들이 많이 나옵니다.
구글에서 "php 파일 업로드 소스"로 검색해 보시면 참고할 소스들이 많이 나옵니다.
http://kr2.php.net/manual/en/features.file-upload.post-method.php
a.php
<html><body>
<form enctype="multipart/form-data" action="b.php" method="POST">
<!-- MAX_FILE_SIZE must precede the file input field -->
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<!-- Name of input element determines name in $_FILES array -->
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
</body></html>
b.php
<?php
include '_common.php';
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES.
$uploaddir = g4['path'].'/school/img/';
$uploadfile = $uploaddir . 'img1.jpg';
echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}
echo 'Here is some more debugging info:';
print_r($_FILES);
print "</pre>";
?>
a.php
<html><body>
<form enctype="multipart/form-data" action="b.php" method="POST">
<!-- MAX_FILE_SIZE must precede the file input field -->
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<!-- Name of input element determines name in $_FILES array -->
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
</body></html>
b.php
<?php
include '_common.php';
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES.
$uploaddir = g4['path'].'/school/img/';
$uploadfile = $uploaddir . 'img1.jpg';
echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}
echo 'Here is some more debugging info:';
print_r($_FILES);
print "</pre>";
?>