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

مساعدة فى كود رفع الملفات للويب

مغلق
بدأه eslam1210 في 19 أغسطس 2007 · 1 رد · 1,737 مشاهدة · في منتدى تطوير المواقع بـ PHP
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم ورحمة الله وبركاته

الاعضاء الكرام

عندى كود برفع منه الملفات على الموقع الخاص بى وشغال تمام

وظيفته

يرفع الملفات من على الكمبيوتر لمكان محدد على الموقع وبعد الرفع يعطينى

حجم الملف المرفوع

نوع الملف المرفوع

امتداد الملف المروفوع

والطلب هل حد يعرف يخليه يطلع رابط الملف المرفوع

وشكرا جزيلا لكم

الكود موجود فى المرفقات

الكود هو

<?php

// specify the directory where the uploaded file should end up

$path = 'upload/' ;

// specify the max filesize in bytes

$max_size = 3000000;

if(isset($HTTP_POST_FILES['userfile']))

{

if(is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name']))

{

if($HTTP_POST_FILES['userfile']['size'] < $max_size)

{

if(!file_exists($path . $HTTP_POST_FILES['userfile']['name']))

{

if(@rename($HTTP_POST_FILES['userfile']['tmp_name'],$path.$HTTP_POST_FILES['userfile']['name']))

{

$html_output = 'file1 sucessful!<br>';

$html_output .= 'File Name: '.$HTTP_POST_FILES['userfile']['name'].'<br>';

$html_output .= 'File Size: '.$HTTP_POST_FILES['userfile']['size'].' bytes<br>';

$html_output .= 'File Type: '.$HTTP_POST_FILES['userfile']['type'].'<br>';

$image = $HTTP_POST_FILES['userfile']['name'] ;

}else{

$html_output = 'file1 failed!<br>';

if(!is_writeable($path))

{

$html_output = 'The Directory "'.$path.'" must be writeable!<br>';

}else{

$html_output = 'an unknown error ocurred.<br>';

}

}

}else{

$html_output = 'The file already exists<br>';

}

}else{

$html_output = 'The file is too big<br>';

}

}

}else{

$html_output = '<form method="post" enctype="multipart/form-data" action="'.$_SERVER['PHP_SELF'].'">';

$html_output .= '<input type="file" name="userfile">';

$html_output .= '<input type="submit" value=" SEND ">';

$html_output .= '</form>';

}

echo '<html><head><title>file1file1er</title></head><body>';

echo $html_output;

echo '</body></html>';

?>

up2.zip

#2

لديك اسم الملف جاهز وكل ماعليك هو تركيب نص المسار الصحيح كالتالي :

$fullpath="http://localhost/up2/".$path;
echo $fullpath.$HTTP_POST_FILES['userfile']['name'];

طبعا المتغير fullpath تضع فيه عنوان الموقع ثم المسار الصحيح وصولا لمجلد السكربت نفسه ..

افترضت في المثال ان السكربت موجود في مجلد اسمه up2 بداخله مجلد اخر اسمه upload

عملية تركيب للمسار الصحيح لااقل ولا اكثر ....

تم تعديل هذه المشاركة بواسطة القرش1 في 21 أغسطس 2007 في 00:00

هذا الموضوع مغلق.

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