Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Your file name you are uploading
- $file_name = $POST['avatar'];
- $userNameToSave = $req_user_info['username'];
- //set where you want to store files
- //in this example we keep file in folder upload
- //$userNameToSave = new upload file name
- //for example upload file name cartoon.gif . $path will be upload/cartoon.gif
- $path= "../users/".$userNameToSave."/images/";
- if($ufile !=none)
- {
- if(copy($POST['avatar']['tmp_name'], $path))
- {
- include("../include/session.php");
- $host="localhost"; // Host name
- $username="root"; // Mysql username
- $password="757794000708"; // Mysql password
- $db_name="IDEA"; // Database name
- $tbl_name="users"; // Table name
- // Connect to server and select database.
- mysql_connect("$host", "$username", "$password")or die("cannot connect");
- mysql_select_db("$db_name")or die("cannot select DB");
- $avatar="../users/".$req_user_info['username']."/".$req_user_info['username'].".jpg";
- $sql="INSERT INTO $tbl_name(avatar)VALUES('$avatar')";
- $result=mysql_query($sql);
- if($result){
- echo "Successful<BR>";
- echo "<a href=../main_page.php>Back to Profile</a>";
- }
- else {
- echo "ERROR";
- }
- mysql_close();
- }
- else
- {
- echo "Error";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement