Root 007
سه شنبه 13 اسفند 1392, 10:12 صبح
سلام به دوستان
من با استفاده از یک فانکش میخوام عمل آپلودینگ انجام بدم ولی به مشکلل بر خوردم اینم از کدهام
function upload_img ($img) {
$arr=array("jpg","png","jpeg","image/jpeg","image/jpg","image/png");
if(in_array($_FILES[$img]["type"], $arr)){
$rnd=rand(100,100000);
$rnd2=rand(300,7879594);
$pic=$rnd.$rnd2.$_FILES[$img]["name"];
copy($_FILES[$img]["tmp_name"],"../img/".$pic);
echo 'inserted';
}
}
if(isset($_POST['sb'])){
$title=$_POST['title'];
$img=$_FILES["fl"];
upload_img($img);
}
HTML CODE
<form method="post" enctype="multipart/form-data"> <input type="file" name="fl"><BR><BR> <input type="submit" name="sb" value="Send"> </form>
Notice: Undefined index: fl
ممنون میشم از راهنماییتون
من با استفاده از یک فانکش میخوام عمل آپلودینگ انجام بدم ولی به مشکلل بر خوردم اینم از کدهام
function upload_img ($img) {
$arr=array("jpg","png","jpeg","image/jpeg","image/jpg","image/png");
if(in_array($_FILES[$img]["type"], $arr)){
$rnd=rand(100,100000);
$rnd2=rand(300,7879594);
$pic=$rnd.$rnd2.$_FILES[$img]["name"];
copy($_FILES[$img]["tmp_name"],"../img/".$pic);
echo 'inserted';
}
}
if(isset($_POST['sb'])){
$title=$_POST['title'];
$img=$_FILES["fl"];
upload_img($img);
}
HTML CODE
<form method="post" enctype="multipart/form-data"> <input type="file" name="fl"><BR><BR> <input type="submit" name="sb" value="Send"> </form>
Notice: Undefined index: fl
ممنون میشم از راهنماییتون