PHP is still more commonly used, I believe we all know its benefits, to show you a PHP upload file code, let's take a look at it. Use the Memory_limit variable to specify a maximum memory capacity variable that can be used by a single script memory_limit value should be appropriately greater than the value of Post_max_size Max_execution_time,max_execution_ Time sets how long PHP waits for the script to complete before forcing the script to terminate, which is calculated in seconds.
This variable is useful when the script enters an infinite loop state. However, this feature also causes the operation to fail when there is a legitimate activity that takes a long time to complete, such as uploading large files. In such cases, you must consider increasing the value of this variable to avoid PHP closing the script for Linux hosts when the script is performing some important process, possibly in/etc/httpd/conf.d/access.conf/ There is also a php.conf file, which may solve some system file size limitation issues.
PHP upload file code
- php
- $ file =$_files[' userfile1 ' [' tmp_name '];
- $ filename =$_files[' userfile1 ' [' name '];
- $ x = Rand (1000,9999);
- $ Tmp_add_pd_path = "./upload/" . $x. ". JPG ";
- if (! $file | | $file= = "None") {
- echo "No";
- }
- else{
- if (Move_uploaded_file ($file, $tmp _add_pd_path)) {
- Echo$filename;
- $ DB = mysql_connect ("localhost", "root", "Wyh7ye");
- mysql_select_db ("Test", $db);
- $ Query = "insertintoproduct (name) VALUES (' $tmp _add_pd_path ')" ;
- $ result = mysql_query ($query, $db);
- $ PID = "selectlast_insert_id ()" ;
- $ Pid_result = mysql_query ($pid, $db);
- $ rows = Mysql_fetch_array ($pid _result);
- $ Tmp_pid = $rows [0];
- $ Tmp_p_type_sql = "Insertintot_product (typeid,pid) VALUES (' $p _type ', ' $tmp _pid ')" ;
- $ result = mysql_query ($tmp _p_type_sql, $db);
- echo "sucess";
- }
- else{
- echo "false";
- }
- }
- ?>
- <br><br>< BR ><br>
- php
- $ DB = mysql_connect ("localhost", "root", "Wyh7ye");
- mysql_select_db ("Test", $db);
- $ Query = "Selectnamefromproduct" ;
- $ result = mysql_query ($query, $db);
- While ($rows=mysql_fetch_array($result)) {
- echo " < imgsrc imgsrc = ". $rows [' name ']." width = the 180height =180 ><br> ";
- }
- ?>
The above is the detailed PHP upload file code, we hope to be helpful.
http://www.bkjia.com/PHPjc/446558.html www.bkjia.com true http://www.bkjia.com/PHPjc/446558.html techarticle PHP is still more commonly used, I believe we all know its benefits, to show you a PHP upload file code, let's take a look at it. Specify a single by Memory_limit variable ...