if(isset($_GET['kaydet'])){
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$filePath = $uploadDir . $fileName;
//<input name="userfile" type="file" id="userfile">
if(mysql_query("INSERT INTO video(name,type,size,path) VALUES ('$tmpName','$fileType','$fileSize','$filePath') "))
{
echo 'Kaydınız gerçekleştirildi.<meta http-equiv="refresh" content="2;URL=index.php">';
}else{
echo "kayit yapilamadi.";
}
}
if(isset($_GET['kat']))
{
$tarih = date('d.m.y');
print "<table width=\"100%\" cellpadding=\"0\" class=\"tfont\" cellspacing=\"0\" border=\"0\">
<form method=\"POST\" action=\"video.php?kaydet\">
<table border=\"0\" width=\"100%\">
<tr>
<td width=\"49%\" class=\"tfont\">►Kategori :</td>
<td width=\"49%\">";?>
<?php
echo "<select style='border-style: solid; border-width: 1; background-color: #4d79bc' class='tfont' size='1' name='1'>";
$kategoriler = mysql_query("SELECT id,kad FROM kategori");
while ($kategori = mysql_fetch_array($kategoriler))
{
echo "<option value='".$kategori['id']."'>".$kategori['kad']."</option>";
}
echo "</select>";
?>
<td width=\"49%\" class=\"tfont\">►Video URL :</td>
<td width=\"49%\"><input name=\"userfile\" type=\"file\" id=\"userfile\" style='border-style: solid; border-width: 1; background-color: #4d79bc' class='tfont'>
file upload
Page 1 of 14 Replies - 994 Views - Last Post: 13 October 2009 - 08:53 AM
#1
file upload
Posted 13 October 2009 - 03:19 AM
hi can someone please help with a problem iv been having. basically the $_FILES['userfile'] doesnt actually get the data and store it. I thought maybe its because of the $_GET method which it still maybe but I worked on this for ver long. I tried echo'ing the data in the $fileType, $fileSize, etc and its empty so theres a problem with the data being parsed. below is the code
Replies To: file upload
#2
Re: file upload
Posted 13 October 2009 - 03:44 AM
Check these some tutorials in Dream.In.Code by Dream.In.Code Experts
Tutorials:
PHP - Uploading a File by e_barroga
Upload A File From A Form by skyhawk133
Uploading Images with PHP by akozlik
File Uploads Tutorial by Pilot-Doofy
Securing File Uploads by Pilot-Doofy
Source Codes:
Smart file upload by Auzzie
File upload with PHP by PsychoCoder
Upload files by William_Wilson
Tutorials:
PHP - Uploading a File by e_barroga
Upload A File From A Form by skyhawk133
Uploading Images with PHP by akozlik
File Uploads Tutorial by Pilot-Doofy
Securing File Uploads by Pilot-Doofy
Source Codes:
Smart file upload by Auzzie
File upload with PHP by PsychoCoder
Upload files by William_Wilson
#3
Re: file upload
Posted 13 October 2009 - 04:02 AM
your problem is in your HTML form, when you want to use file with form then form's enctype must be application/x-www-form-urlencoded
<form action="" method="post" enctype="application/x-www-form-urlencoded" name="form1">
<form action="" method="post" enctype="application/x-www-form-urlencoded" name="form1">
#4
Re: file upload
Posted 13 October 2009 - 04:55 AM
well guys I'm affraid it still aint working there is nothing wrong with the upload script as I used this code on another form with direct html rather then being echod and it works fine. also another thing that I shoulf have mensioned is that other data is passed from the forms
example: Code snippet (not the hole code)
you see this code works fine. the file is added to the sql database
what messes up is if i add
You see the data gotten from userfile is not passed to example: $fileName = $_FILES['userfile']['name']; or any of the others. I hope I never confused anyone.
example: Code snippet (not the hole code)
$a = $_POST['1'];
$b = $_POST['2'];
$c = $_POST['userfile'];
$d = $_POST['4'];
$e = $_POST['5'];
$f = $_POST['6'];
$g = $_POST['7'];
$h = 0;
if(mysql_query("INSERT INTO video(kid,ad,url,rurl,aciklama,tarih,tur,hit,name,type,size,path) VALUES ('$a','$b','$c','$d','$e','$f','$g','$h') "))
{
echo 'Kaydınız gerçekleştirildi.<meta http-equiv="refresh" content="2;URL=index.php">';
}else{
echo "kayit yapilamadi.";
}
}
//<form action="" method="post" enctype="application/x-www-form-urlencoded" name="form1">
if(isset($_GET['kat']))
{
$tarih = date('d.m.y');
print "<table width=\"100%\" cellpadding=\"0\" class=\"tfont\" cellspacing=\"0\" border=\"0\">
<form method=\"POST\" action=\"video.php?kaydet\" enctype=\"application/x-www-form-urlencoded\">
<table border=\"0\" width=\"100%\">
<tr>
<td width=\"49%\" class=\"tfont\">►Kategori :</td>
<td width=\"49%\">";?>
<?php
echo "<select style='border-style: solid; border-width: 1; background-color: #4d79bc' class='tfont' size='1' name='1'>";
$kategoriler = mysql_query("SELECT id,kad FROM kategori");
while ($kategori = mysql_fetch_array($kategoriler))
{
echo "<option value='".$kategori['id']."'>".$kategori['kad']."</option>";
}
echo "</select>";
?>
<?php echo "</td>
</tr>
<tr>
<td width=\"49%\" class=\"tfont\">►Video Adı :</td>
<td width=\"49%\"><input type=\"text\" style='border-style: solid; border-width: 1; background-color: #4d79bc' class='tfont' name=\"2\" value=\"\"size=\"27\"></td>
</tr>
<tr>
you see this code works fine. the file is added to the sql database
what messes up is if i add
$uploadDir = '/home/sites/sinan.com/public_html/upload/upload_file/';
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$filePath = $uploadDir . $fileName;
$result = move_uploaded_file($tmpName, $filePath);
if (!$result) {
echo "Error uploading file";
exit;
}
include 'config.php';
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}
<td width=\"49%\" class=\"tfont\">►Video URL :</td>
<td width=\"49%\"><input name=\"userfile\" type=\"file\" id=\"userfile\" style='border-style: solid; border-width: 1; background-color: #4d79bc' class='tfont'>
You see the data gotten from userfile is not passed to example: $fileName = $_FILES['userfile']['name']; or any of the others. I hope I never confused anyone.
This post has been edited by sinans11: 13 October 2009 - 04:59 AM
#5
Re: file upload
Posted 13 October 2009 - 08:53 AM
noorahmad thanks for you help what you said was write but also
I had forgotten to declare the name on the submit button. once i sorted that out I was able to call the POST method which sorted the problem out.
Thanks anyway man appreciated
I had forgotten to declare the name on the submit button. once i sorted that out I was able to call the POST method which sorted the problem out.
Thanks anyway man appreciated
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote



|