PHP はまだ比較的一般的に使用されており、その利点は皆さんもご存知だと思います。PHP ファイルのアップロード コードを一緒に見てみましょう。単一のスクリプト プログラムが使用できる最大メモリ容量を指定するには、memory_limit 変数を使用します。変数memory_limit の値は、post_max_size の値より適切に大きい必要があります。 max_execution_time は、PHP がスクリプトが強制的に実行されるまで待機する時間を設定します。スクリプトの終了時間は秒単位で計算されます。
PHPアップロードファイルコード
<ol class="dp-xml"> <li class="alt"> <span><strong><font color="#006699"><span class="tag"><?</SPAN><SPAN class=tag-name>php</SPAN></FONT></STRONG><SPAN> </SPAN></SPAN><LI class=""><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>file</FONT></SPAN><SPAN>=$_FILES['userfile1']['tmp_name']; </SPAN></SPAN><LI class=alt><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>filename</FONT></SPAN><SPAN>=$_FILES['userfile1']['name']; </SPAN></SPAN><LI class=""><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>x</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>rand</FONT></SPAN><SPAN>(1000,9999); </SPAN></SPAN><LI class=alt><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>tmp_add_pd_path</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>"./upload/"</FONT></SPAN><SPAN>.$x.".jpg"; </SPAN></SPAN><LI class=""><SPAN>if(!$file||$</SPAN><SPAN class=attribute><FONT color=#ff0000>file</FONT></SPAN><SPAN>=="none"){ </SPAN></SPAN><LI class=alt><SPAN>echo"no"; </SPAN><LI class=""><SPAN>} </SPAN><LI class=alt><SPAN>else{ </SPAN><LI class=""><SPAN>if(move_uploaded_file($file,$tmp_add_pd_path)){ </SPAN><LI class=alt><SPAN>echo$filename; </SPAN><LI class=""><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>db</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>mysql_connect</FONT></SPAN><SPAN>("localhost","root","wyh7ye"); </SPAN></SPAN><LI class=alt><SPAN>mysql_select_db("test",$db); </SPAN><LI class=""><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>query</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>"INSERTintoproduct(name)values('$tmp_add_pd_path')"</FONT></SPAN><SPAN>; </SPAN></SPAN><LI class=alt><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>result</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>mysql_query</FONT></SPAN><SPAN>($query,$db); </SPAN></SPAN><LI class=""><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>pid</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>"SELECTLAST_INSERT_ID()"</FONT></SPAN><SPAN>; </SPAN></SPAN><LI class=alt><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>pid_result</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>mysql_query</FONT></SPAN><SPAN>($pid,$db); </SPAN></SPAN><LI class=""><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>rows</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>mysql_fetch_array</FONT></SPAN><SPAN>($pid_result); </SPAN></SPAN><LI class=alt><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>tmp_pid</FONT></SPAN><SPAN>=$rows[0]; </SPAN></SPAN><LI class=""><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>tmp_p_type_sql</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>"INSERTintot_product(typeid,pid)values('$p_type','$tmp_pid')"</FONT></SPAN><SPAN>; </SPAN></SPAN><LI class=alt><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>result</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>mysql_query</FONT></SPAN><SPAN>($tmp_p_type_sql,$db); </SPAN></SPAN><LI class=""><SPAN>echo"sucess"; </SPAN><LI class=alt><SPAN>} </SPAN><LI class=""><SPAN>else{ </SPAN><LI class=alt><SPAN>echo"false"; </SPAN><LI class=""><SPAN>} </SPAN><LI class=alt><SPAN>} </SPAN><LI class=""><SPAN></SPAN><SPAN class=tag><STRONG><FONT color=#006699>?></span></font></strong></span><span> </span> </li> <li class="alt"> <span></span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>br</SPAN><SPAN class=tag>></span><span class="tag"><</SPAN><SPAN class=tag-name>br</SPAN><SPAN class=tag>></span><span class="tag"><</SPAN><SPAN class=tag-name>br</SPAN><SPAN class=tag>></span><span class="tag"><</SPAN><SPAN class=tag-name>br</SPAN><SPAN class=tag>></span></font></strong><span> </span> </li> <li class=""> <span></span><strong><font color="#006699"><span class="tag"><?</SPAN><SPAN class=tag-name>php</SPAN></FONT></STRONG><SPAN> </SPAN></SPAN><LI class=alt><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>db</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>mysql_connect</FONT></SPAN><SPAN>("localhost","root","wyh7ye"); </SPAN></SPAN><LI class=""><SPAN>mysql_select_db("test",$db); </SPAN><LI class=alt><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>query</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>"selectnamefromproduct"</FONT></SPAN><SPAN>; </SPAN></SPAN><LI class=""><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>result</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>mysql_query</FONT></SPAN><SPAN>($query,$db); </SPAN></SPAN><LI class=alt><SPAN>while($</SPAN><SPAN class=attribute><FONT color=#ff0000>rows</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>mysql_fetch_array</FONT></SPAN><SPAN>($result)){ </SPAN></SPAN><LI class=""><SPAN>echo"</SPAN><SPAN class=tag><STRONG><FONT color=#006699><</FONT></STRONG></SPAN><SPAN class=attribute><FONT color=#ff0000>imgsrc</FONT></SPAN><SPAN class=tag-name><STRONG><FONT color=#006699>imgsrc</FONT></STRONG></SPAN><SPAN>=".$rows['name']."</SPAN><SPAN class=attribute-value><FONT color=#0000ff>width</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>180</FONT></SPAN><SPAN class=attribute><FONT color=#ff0000>180height</FONT></SPAN><SPAN>=180</SPAN><STRONG><FONT color=#006699><SPAN class=tag>></span><span class="tag"><</SPAN><SPAN class=tag-name>br</SPAN><SPAN class=tag>></span></font></strong><span>"; </span> </li> <li class="alt"><span>} </span></li> <li class=""> <span></span><span class="tag"><strong><font color="#006699">?></font></strong></span><span> </span> </li> </ol>
上記は詳細なPHPファイルアップロードコードです。皆様のお役に立てれば幸いです。