PDA

View Full Version : سوال: مشکل در ارسال اطلاعات حجیم از یک فرم به صفحه دیگر



mhofayyaz
یک شنبه 31 شهریور 1387, 11:02 صبح
سلام
من یه صفحه به نام add.php دارم که مقاله رو به do.add.php می فرستم . اما اگه مقاله حجمش زیاد باشه ، بهش گیر می ده . وقتی بررسی می کنم ، می بینم که اصلاً نمی تونه $_POST["atxtFullstory"] رو دریافت کنه و می گه که خالیه ! ! اما روی لوکال که تست می کنم ، همون مقاله با موفیت ارسال میشه ! دلیلش چیه ؟ مشکل از سیشن هم نیست . چون سیشن رو هم برداشتم ولی کار نکرد . حتی تو صفحه do.add.php کد زیر رو میذارم ، مقاله های حجیم رو خالی نشون می ده و مگه چیزی ارسال نشده :

<?php
die($_POST["atxtFullstory"]);
?>

کد add.php :


<?php
defined("_nayzar_admin__") or die("invalid request");
$title="ارسال مطلب";
$sql="SELECT * FROM category WHERE Org='1'";
$result=@mysql_query($sql);
while($row=@mysql_fetch_assoc($result))
{
$categories[]=$row;
}
$count=count($categories);
include("includes/header.inc.php");
?>
<script LANGUAGE="JavaScript">
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,men ubar=0,resizable=0,width=400,height=50,left = 100,top = 120');");
}
</script>
<script type="text/javascript">
_editor_url = "../";
_editor_lang = "en";
</script>
<script type="text/javascript" src="../htmlarea.js"></script>
<script type="text/javascript">
HTMLArea.loadPlugin("TableOperations");
HTMLArea.loadPlugin("SpellChecker");
HTMLArea.loadPlugin("CSS");
function initDocument() {
var css_plugin_args = {
combos : [
{ label: "Syntax",
options: { "None" : "",
"Code" : "code",
"String" : "string",
"Comment" : "comment",
"Variable name" : "variable-name",
"Type" : "type",
"Reference" : "reference",
"Preprocessor" : "preprocessor",
"Keyword" : "keyword",
"Function name" : "function-name",
"Html tag" : "html-tag",
"Html italic" : "html-helper-italic",
"Warning" : "warning",
"Html bold" : "html-helper-bold"
},
context: "pre"
},
{ label: "Info",
options: { "None" : "",
"Quote" : "quote",
"Highlight" : "highlight",
"Deprecated" : "deprecated"
}
}
]
};
var editor1 = new HTMLArea("text-area-1");
editor1.registerPlugin(TableOperations);
editor1.registerPlugin(SpellChecker);
editor1.registerPlugin(CSS, css_plugin_args);
editor1.config.pageStyle = "@import url(dynamic.css);";
editor1.generate();
var editor2 = new HTMLArea("text-area-2");
editor2.registerPlugin(TableOperations);
editor2.registerPlugin(SpellChecker);
editor2.registerPlugin(CSS, css_plugin_args);
editor2.config.pageStyle = "@import url(dynamic.css);";
setTimeout(function() {
editor2.generate();
}, 500);
//---------------------------------------------------------------------
};

HTMLArea.init();
HTMLArea.onload = initDocument;

</script>
<?php
echo Fform("index.php?p=2","addnews","");
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" dir="rtl">
<tr>
<?php
if($_SESSION["Add_news_MSG"])
{
echo $_SESSION["Add_news_MSG"];
$_SESSION["Add_news_MSG"]="";
}
?>
</p></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>تيتر مطلب :</td>
<td><label>
<input name="atxtTitle" type="text" value="<?php echo $_SESSION["atxtTitle"]; ?>" size="60">
</label></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>نویسنده : </td>
<td><input name="txtWriter" type="text" value="<?php echo $_SESSION["txtWriter"]; ?>" size="40" /></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td height="35">موضوع</td>
<td><select name="atxtCategory" id="atxtCategory">
<?php
for($i=0;$i<$count;$i++)
{
$category=$categories[$i];
$id=$category["ID"];
$name=$category["Name"];
$main=$category["Main"];
if($main=='0')
{
for($f=0;$f<$count;$f++)
{
$category2=$categories[$f];
$id2=$category2["ID"];
$name2=$category2["Name"];
$main2=$category2["Main"];
if($main2==$id)
{
?>
<option value="<?php echo $id2; ?>" <?php if($_SESSION["atxtCategory"]==$id2) echo "selected"; ?>><?php echo $name."->".$name2; ?></option>
<?php
}
}
}
}
?>
</select></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>عکس : </td>
<td><input dir="rtl" name="txtSImage" type="text" value="<?php echo $_SESSION["txtSImage"]; ?>" size="60" />
<a href=javascript:popUp("../home.php?p=4") title="ارسال عکس" rel="category tag">ارسال عکس</a></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>خلاصه خبر : </td>
<td><label>
<textarea id="text-area-1" name="atxtShortstory" style="width: 150%; height: 30em; background:#FFFFFF">
<?php echo $_SESSION["atxtShortstory"]; ?>
</textarea>
</label></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>متن کامل : </td>
<td>
<textarea id="text-area-2" name="atxtFullstory" style="width: 100%; height: 30em; background:#FFFFFF">
<?php echo $_SESSION["atxtFullstory"]; ?>
</textarea>
</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>نمایش خبر : </td>
<td>بله <input type="radio" value="0" name="Active" <?php if($_SESSION["Active"]==1 || !$_SESSION["Active"]) echo "checked"; ?>/> خیر <input type="radio" value="1" name="Active" <?php if($_SESSION["Active"]==2) echo "checked"; ?>/></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<input type="submit" name="Submit" value="ارسال"> </td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
</form>
<?php
echo Llink("index.php","back","","بازگشت به صفحه اصلی<br>");
include("includes/footer.inc.php");
?>

do.add.php :

<?php

defined("_nayzar_admin__") or die("invlaid request");



$title=$_SESSION["atxtTitle"]=htmlspecialchars($_POST["atxtTitle"]);

$writer=$_SESSION["txtWriter"]=htmlspecialchars($_POST["txtWriter"]);

$category=$_SESSION["atxtCategory"]=htmlspecialchars($_POST["atxtCategory"]);

$image=$_SESSION["txtSImage"]=htmlspecialchars($_POST["txtSImage"]);

$shortstory=$_SESSION["atxtShortstory"]=trim($_POST["atxtShortstory"]);

$fullstory=$_SESSION["atxtFullstory"]=$_POST["atxtFullstory"];

//$fullstory=str_replace('\\','',$fullstory1);



if(!$category)

{

$_SESSION["Add_news_MSG"]="لطفاً موضوع را انتخاب کنيد !";

Redirect("index.php?p=1");

}



if(!$shortstory)

{

$_SESSION["Add_news_MSG"]="لطفاً خطلاصه خبر مطلب را وارد کنيد !";

Redirect("index.php?p=1");

}



if(!$fullstory)

{

$_SESSION["Add_news_MSG"]="لطفاً خبر کامل مطلب را وارد کنيد !";

Redirect("index.php?p=1");

}



if(!$image)

{

$_SESSION["Add_news_MSG"]="لطفاً عکس خبر را انتخاب کنید";

Redirect("index.php?p=1");

}



//End Write

$date=date("Y-m-d");



$sql="INSERT INTO news

(Title, Writer, Category, Image, Shortstory, Fullstory, Date, Active)

VALUES ('$title', '$writer', '$category', '$image', '$shortstory', '$fullstory', '$date', '$active')";

if(!@mysql_query($sql))

{

$_SESSION["Add_news_MSG"]="There is an error ! Please try later!";

Redirect("index.php?p=1");

}



$_SESSION["atxtTitle"]="";

$_SESSION["atxtCategory"]="";

$_SESSION["txtWriter"]="";

$_SESSION["atxtShortstory"]="";

$_SESSION["atxtFullstory"]="";

$_SESSION["Active"]="";

$_SESSION["txtSImage"]="";



$_SESSION["Add_news_MSG"]="مطلب با موفقیت ثبت شد!";

Redirect("index.php?p=1");

?>

narsic
یک شنبه 31 شهریور 1387, 21:48 عصر
با سلام
دوست عزیز برای ارسال اطلاعات توسط متد پست یک محدودیت وجود دارد که باید برای ارسال اطلاعات حجیم این محدودیت رو در فایل php.ini تنظیم کنید .
من کد بالا رو نخوندم و پاسخ بر اساس این بود که کد بالا صحیح باشه .
موفق بتشید .

mhofayyaz
دوشنبه 01 مهر 1387, 03:56 صبح
این محدودیت در کجای php .ini درج شده ؟

ali_sed
دوشنبه 01 مهر 1387, 09:38 صبح
Howto optimize your PHP installation to handle large file uploads.

Though PHP presents a very versatile and user friendly interface for handling file uploads, the default installation is not geared for working with files in excess of 2 Mega Bytes. This article will help you configure your PHP engine for handling such large file transfers.
The php.ini File

Special Note:

You could be wasting bandwidth, If your file upload page is nothing more than an HTML form.

Most browsers just ignore the MAX_FILE_SIZE hidden field and size limits are checked only after the data has been sent over the wire.

Our applet saves your bandwidth by imposing client side restrictions.



All the configuration settings for your installation are contained in the php.ini file. Sometimes these setting might be overridden by directives in apache .htaccess files or even with in the scripts themselves. However you cannot over ride some of the settings that effect file uploads with .htaccess directives in this way. So let's just concentrate on the ini file. If you do not have access to your PHP configuration file you can use the applet in resumable mode

You can call the phpinfo() function to find the location of your php.ini file, it will also tell you the current values for the following settings that we need to modify
file_uploads
upload_max_filesize
max_input_time
memory_limit
max_execution_time
post_max_size

The first one is fairly obvious if you set this off, uploading is disabled for your installation. We will cover the rest of the configuration settings in detail below.
upload_max_filesize and post_max_size

Files are usually POSTed to the webserver in a format known as 'multipart/form-data'. The post_max_size sets the upper limit on the amount of data that a script can accept in this manner. Ideally this value should be larger than the value that you set for upload_max_filesize.

It's important to realize that upload_max_filesize is the sum of the sizes of all the files that you are uploading. post_max_size is the upload_max_filesize plus the sum of the lengths of all the other fields in the form plus any mime headers that the encoder might include. Since these fields are typically small you can often approximate the upload max size to the post max size.

According to the PHP documentation you can set a MAX_UPLOAD_LIMIT in your HTML form to suggest a limit to the browser. Our understanding is that browsers totally ignore this directive and the only solution that can impose such a client side restriction is our own Rad Upload Applet
memory_limit
When the PHP engine is handling an incoming POST it needs to keep some of the incoming data in memory. This directive has any effect only if you have used the --enable-memory-limit option at configuration time. Setting too high a value can be very dangerous because if several uploads are being handled concurrently all available memory will be used up and other unrelated scripts that consume a lot of memory might effect the whole server as well.
max_execution_time and max_input_time
These settings define the maximum life time of the script and the time that the script should spend in accepting input. If several mega bytes of data are being transfered max_input_time should be reasonably high. You can override the setting in the ini file for max_input_time by calling the set_time_limit() function in your scripts.


Additonal Comments
Apache Settings

The apache webserver has a LimitRequestBody configuration directive that restricts the size of all POST data regardless of the web scripting language in use. Some RPM installations sets limit request body to 512Kb. You will need to change this to a larger value or remove the entry altogether.
Other Options

If you expect to handle a large number of concurrent file transfers on your website consider using a perl or java server side component. PHP happens to be our favourite web programming language as well but perl and Java are just slightly ahead when it comes to file upload.

Most installations of perl as an apache module can accept in excess of 32 megabytes out of the box. Compare this against the 2MB default for PHP. The downside is that perl coding takes just a bit more effort than PHP but it's worth it. You can try our sample scripts to get started.


منبع : http://www.radinks.com

لینک مقاله : http://www.radinks.com/upload/config.php

mhofayyaz
دوشنبه 01 مهر 1387, 10:19 صبح
اینکه مال فایله !!!
اطلاعات من نوشته هست

as13851365
دوشنبه 01 مهر 1387, 11:48 صبح
; Maximum size of POST data that PHP will accept.
post_max_size = 8M


; Maximum allowed size for uploaded files.
upload_max_filesize = 2M

narsic
دوشنبه 01 مهر 1387, 22:58 عصر
; Maximum size of POST data that PHP will accept.
post_max_size = 8M
; Maximum allowed size for uploaded files.
upload_max_filesize = 2M
اینجاش هست