<?php
$a="i live at wanra at kolhapur in india";
setcookie('file',$a);
?>
<html>
<body>
<form action ="fileupload2.php" method="post">
<input type ="submit" value ="submit">
</form>
</body>
</html>
this is my first page and then
<?php
$val1 = $_COOKIE['file'];
$val11 = "mememememememe";
$file_name="/home/an1.crt";
if(file_exists($file_name))
{
echo ("$file_name does exsist");
}
else
{
echo ("$file_name does'nt exsist");
touch ($file_name);
}
$fd1 = fopen ($file_name, "w+");
$newcontent = file_put_contents ($file_name,$val1);
fclose ($fd1);
$picture =$newcontent;
echo $picture;
?>
<?php
function UploadOne($fname)
{
$uploaddir = "/home/test1/";
if (is_uploaded_file($fname['tmp_name']))
{
$filname = basename($fname['name']);
$uploadfile = $uploaddir . basename($fname['name']);
if (move_uploaded_file ($fname['tmp_name'], $uploadfile))
$res = "File " . $filname . " was successfully uploaded and stored.<br>";
else
$res = "Could not move ".$fname['tmp_name']." to ".$uploadfile."<br>";
}
else
$res = "File ".$fname['name']." failed to upload.";
return ($res);
}
?>
<?php
if ($_FILES['picture']['name'] != "")
{
$res = UploadOne($_FILES['picture']);
$filname = $_FILES['picture']['name'];
echo ($res);
}
?>
in this page i want to upload file please help me to upload file by putting content of a variable in a file and then uploading it.please help me to find the bug..............
and please tell me what is tmp_name,picture,all variable ?
and what should i use in place of those variable to upload my file.