php image uploader which upload and rename file then insert the path in mysql -
Guys, need a PHP script that safely uploads images and changing the names of those with user ID and then update the MySQL database ISL path. Thank you in advance.
"Post-text" Aitmprop = "text">
Use the code below Krenkkman U demo code Daito ... according to your requirement make changes.
Pre-upload an image upload control in the design file.
& lt; Form action = "process.php" method = "post" & gt; & Lt; Input type = "file" name = "file" id = "file" /> & Lt; Input type = "submit" value = "submit" /> & Lt; / Form & gt; The code cast went PHP code file below I made process.php, but you can create a php file with any name, but make sure, form php file in action Pass the name of the property above.
The process. Php
& lt ;? Includes Php ('connection.php'); If ($ _FILES ["file"] ["error"]> gt; 0) {resonant "sorry, there was an error."; Echo "Error Code:" $ _ Files ["file"] ["error"]; } And {$ sql = "select * from TABLE_NAME"; $ Query = mysql_query ($ sql) or die ("query failed". Mysql_error ()); If (mysql_num_rows ($ query) & gt; {0} {$ sql = "select maximum (ID) from TABLE_NAME"; $ Query = mysql_query ($ sql) or die ("query failed". Mysql_error ()); While ($ line = mysql_fetch_array ($ query)) {$ id = $ line [0]; }} And {$ id = '1'; } Move_uploaded_file ($ _ FILES [ "file"] [ "tmp_name"], "Folder name /. $ Id. $ _ FILES [" file "] [" name "]); $ Queryl =" table name (image) VALUES Insert ($. $ $ $ $ $ _ fILES [ "file"] [ "name"]. " '") or die ( "query failed 1". Mysql_error ()); Mysql_query ($ query1) or die ("query failed 1" .mysql_error ()); }
Comments
Post a Comment