الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

مشكله كود رفع ملفين معا

بدأه man in dark في 31 أغسطس 2011 · 5 رد · 487 مشاهدة · في منتدى تطوير المواقع بـ PHP
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

اخواني الكود كان يعمل 100% في ادخال البيانات

بس اضفت للكود خانتين لرفع الملفات وهما

	<tr>
		<td>ملف</td>
		<td><input name="fileanme" type="file" id="fileanme" ></td>
	</tr>
	<tr>
		<td>صورة</td>
		<td><input name="image" type="file" id="image" ></td>
	</tr>

المشكله الان لم يعمل معي الكود في رفع الملفات الى المجلد Upload وتخزين البيانات في قاعدة البيانات

لو ممكن المساعده في حل هذا الكود

الكود كامل

<?php
session_start();
if(!session_is_registered(myusername)){
header("location:../login.php");
}

include('../config.php');


$fullname2=$_SESSION['fullname'] ;
$employeeid2=$_SESSION['employeeid'] ;




if($_GET['action']=="maumt"){ 



$timebetx=date('Y-m-d H:i:s',time());


$filename = $_FILES['file']['name'];
$type1 = $_FILES['file']['type'];
$image = $_FILES['file2']['name'];
$type2 = $_FILES['file2']['type'];
if($_POST[upload] == "1")
	{
	$to = "upload/".$_FILES['file']['name'];
	move_uploaded_file($_FILES['file']['tmp_name'], $to);
	$to = "upload/".$_FILES['file2']['name'];
	move_uploaded_file($_FILES['file2']['tmp_name'], $to);





$filename=$filename;
$type1=$type1;
$image=$image;
$type2=$type2;

$author=$_POST['author'];
$idauthor=$_POST['idauthor'];
$title=$_POST['title'];
$info=$_POST['info'];
$datatitle=$_POST['datatitle'];


$sql="INSERT INTO qatitle  (id, author, idauthor, title, info, datatitle, filename, type1, image, type2) VALUES
('', '$author', '$idauthor', '$title','$info', '$timebetx', '$filename', '$type1', '$image', '$type2')";


mysql_query($sql);
$idsas = mysql_insert_id();
$sql = "UPDATE qatitle SET idtitle = '$idsas' WHERE id = '$idsas'";
mysql_query($sql); 

$result=mysql_query($sql) or die(mysql_error());  




if($result){



$question=$_POST['question'];
$answer1=$_POST['answer1'];
$choose1=$_POST['choose1'];
$answer2=$_POST['answer2'];
$choose2=$_POST['choose2'];
$answer3=$_POST['answer3'];
$choose3=$_POST['choose3'];
$answer4=$_POST['answer4'];
$choose4=$_POST['choose4'];

$sql2="INSERT INTO qquiz  (id, question, idtitle, answer1, choose1, answer2, choose2, answer3, choose3, answer4, choose4) VALUES
('', '$question', '$idsas', '$answer1','$choose1', '$answer2','$choose2','$answer3', '$choose3','$answer4','$choose4')";



$result2=mysql_query($sql2) or die(mysql_error());  

if($result2){
}

else {
$result2=mysql_query($sql2) or die(mysql_error());  
}


}
else {
echo "<center>خطاء في ادخال البيانات الرجاء الاتصال بالدعم الفني</center>";
}}}
?>
<html dir="rtl" xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />








</head>
<body>



	<div class="content">
		<div id="articles">
			<div id="left">



<td><form name="maumt" method="post" action="maumt.php?action=maumt"></td>
<td><h2><a href="#">الجدول الاول</a></h2></td>
<br>
<table border="0" width="100%" dir="rtl" >
	<tr>
<input name="author" type="hidden" id="author" value="<?php echo $fullname2;  ?>"/>
<input name="idauthor" type="hidden" id="idauthor" value="<?php echo $employeeid2;  ?>"/>

	<tr>
		<td>اسم</td>
		<td><input name="title" type="text" id="title" ></td>
	</tr>
	<tr>
		<td height="31">ممعلومات</td>
		<td rowspan="2"><textarea rows="8" name="info" cols="40"  style="color: #000000"></textarea></td>
	<tr>
		<td></td>
	</tr>
	</tr>


	<tr>
		<td>ملف</td>
		<td><input name="fileanme" type="file" id="fileanme" ></td>
	</tr>
	<tr>
		<td>صورة</td>
		<td><input name="image" type="file" id="image" ></td>
	</tr>



	<tr>
	<td height="30"></td>	<td height="30"></td>

	</tr>

		<tr>
	<td colspan="2"><h2><a href="#">ادخال جدول اخر</a></h2></td>
	</tr>

	<tr>
		<td>مكون</td>
		<td><input name="question" type="text" id="question" size="40"></td>
	</tr>
	<tr>
		<td>1</td>
		<td><input name="choose1" type="text" id="choose1" > <input name="answer1" type="text" id="answer1" size="5" value="0"></td>
	</tr>
	<tr>
		<td>2</td>
		<td><input name="choose2" type="text" id="choose2" > <input name="answer2" type="text" id="answer2" size="5" value="0"></td>
	</tr>
	<tr>
		<td>3</td>
		<td><input name="choose3" type="text" id="choose3" > <input name="answer3" type="text" id="answer3" size="5" value="0"></td>
	</tr>
	<tr>
		<td>4</td>
		<td><input name="choose4" type="text" id="choose4" > <input name="answer4" type="text" id="answer4" size="5" value="0"></td>
	</tr>	



	<tr>
		<td height="15"></td>
		<td height="15"></td>
	</tr>


	<tr>
	<input type="hidden" name="upload" value="1">

        <td><input type="submit" name="Submit" value=" إرسال " ></td>
	</tr>

   </tr>

</table>





			</div>



</body>	
</html>

للمعلوميه لايظهر رساله خطاء لذلك لا اعرف المشكله من اين....

#2

طيب ايه الخطأ اللى بيظهر ؟

Life is not the amount of breaths you take, it's the moments that take your breath away

#3

مثل ماقلت اخي فؤاد عبد الرازق.....

للمعلوميه لايظهر رساله خطاء لذلك لا اعرف المشكله من اين....

#4

اولا ضع خاصية enctype="multipart/form-data"

في الفورم

<form  enctype="multipart/form-data"  name="maumt"...

صحح اسم الملف في الادخال بـ filename

الاسم اكيد مش هوا المشكلة

المشكل من السطور التالية

$filename = $_FILES['file']['name'];
$type1 = $_FILES['file']['type'];
$image = $_FILES['file2']['name'];
$type2 = $_FILES['file2']['type'];
if($_POST[upload] == "1")
        {
        $to = "upload/".$_FILES['file']['name'];
        move_uploaded_file($_FILES['file']['tmp_name'], $to);
        $to = "upload/".$_FILES['file2']['name'];
        move_uploaded_file($_FILES['file2']['tmp_name'], $to);

استبدلها بـ

$filename = $_FILES['filename']['fiile'];
$type1 = $_FILES['filename']['type'];
$image = $_FILES['image']['name'];
$type2 = $_FILES['image']['type'];
if($_POST["upload"] == "1")
    	{
    	$to = "upload/".$_FILES['filename']['name'];
    	move_uploaded_file($_FILES['filename']['tmp_name'], $to);

    	$to = "upload/".$_FILES['image']['name'];
    	move_uploaded_file($_FILES['image']['tmp_name'], $to);

مع ملاحظة اني اختبرت فقط هذا الجزء اما باقي الكود فانت ادرى به

تحياتي

تم تعديل هذه المشاركة بواسطة ihope في 31 أغسطس 2011 في 09:30

1

other ESTJ thing

اقتباس
Help Me To Help You

0xBAD00DAD.png

#5

اخوي يوجد مشكله الان

...... انه لايسجل اسم الملف الاول في قاعدة البيانات في خانه filename

مع انه تم التاكد من الحقل الاول

        <tr>
                <td>ملف</td>
                <td><input name="fileanme" type="file" id="fileanme" ></td>
        </tr>

وتم التاكد من قاعدة البيانات ان اسم الحقل filename ولكن لايسجل الاسم فقط يرفع الملف الى مجلد upload

ويظهر الرساله في اعلى المتصفح باسم الملف ونوعه وحجمه والرساله هي...

array ( 'filename' => array ( 'name' => 'habilidoso_HB.wmv', 'type' => 'video/x-ms-wmv', 'tmp_name' => 'C:/camel/tmp\\php41A.tmp', 'error' => 0, 'size' => 1600799, ), 'image' => array ( 'name' => 'نص.txt', 'type' => 'text/plain', 'tmp_name' => 'C:/camel/tmp\\php41B.tmp', 'error' => 0, 'size' => 1789, ), )

هذه هي البيانات التي تسجل في قاعدة البيانات 100%

$type1 = $_FILES['filename']['type'];
$image = $_FILES['image']['name'];
$type2 = $_FILES['image']['type'];

تم تعديل هذه المشاركة بواسطة man in dark في 31 أغسطس 2011 في 10:44

#6

اخي تم حل المشكله وذلك بالتعديل على السطر هذا فقط

$filename = $_FILES['filename']['fiile'];

واستبداله

$filename = $_FILES['filename']['name'];

تم تعديل هذه المشاركة بواسطة man in dark في 31 أغسطس 2011 في 10:50

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…