Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 962563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:31:40+00:00 2026-05-16T01:31:40+00:00

I have a file upload script that works [finally] but want to have users

  • 0

I have a file upload script that works [finally] but want to have users submit pics into a folder, which I want to be created as the users name. I was thinking I could just maybe submit the file and then it would jsut create it, but it didn’t, so how can I do this? This is my script:
PHP Code:

<?php 
// Configuration part  
$dbhost = "localhost"; // Database host  
$dbname = "users"; // Database name  
$dbuser = "dbuser"; // Database username  
$dbpass = ""; // Database password  

// Connect to database  
$db = mysql_connect($dbhost, $dbuser, $dbpass) or die("Error: Couldn't connect to database");  
mysql_select_db($dbname, $db) or die("Error: Couldn't select database.");  

if($IsLoggedIn) 
{ $userid = $_GET["userid"]; 
    if($_POST['Submit']) 
        { 

            if($userid) 
            { $uploadName = mysql_query("SELECT * FROM users WHERE userId ='" 
                             . $userid . "'"); 
            while ($upName = mysql_fetch_row($uploadName)) 
                { $userName2 = $upName[1]; 
                   $userPic1 = $upName[11];  
                   echo "$userName2"; } } 

//If the Submitbutton was pressed do:  

            if ($_FILES['imagefile']['type'] == 'image/pjpeg') 
                {  

//this is where the pic is put into a folder by the username 
    copy ($_FILES['imagefile']['tmp_name'],  
    "pics/profiles/" . $userName2 . "/" . $_FILES['imagefile']['name'])  
    or die ("Could not copy");  

        echo "";  
        echo "Name: ".$_FILES['imagefile']['name']."";  
        echo "Size: ".$_FILES['imagefile']['size']."";  
        echo "Type: ".$_FILES['imagefile']['type']."";  
        echo "Copy Done....";  
        }  


        else {  
            echo "";  
            echo "Could Not Copy, Wrong Filetype (".$_FILES['imagefile']['name'].")";  
        }  
}  

?> 
<form name="form1" method="post" action="index.php?page=classupload&userid=<?php echo "$userid"; ?>" enctype="multipart/form-data">  
<input type="file" name="imagefile">  

<input type="submit" name="Submit" value="Submit">  
</form> 
<?php } else { ?>How did you get here? You aren't <a href="index.php?page=login">Logged In</a>. 
<?php } ?>

is there any way to do this? Maybe even when the user is made? thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T01:31:41+00:00Added an answer on May 16, 2026 at 1:31 am
    $directoryPath = "/home/domain/public_html/site_name/pics/profiles/".$userName2;
    mkdir($directoryPath, 0644);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an upload script that write a index.html file, I modified it to
So I have an upload script, and I want to check the file type
All Gmail users should have already noticed that file upload progress bar has been
I have a simple swf file upload script that uploads a file as soon
I have a question. I have a script that handles file upload, and after
I have a script that performs some simple editing which works fine, the problem
I have this simple script which works fine, but currently overwrites files with duplicate
I have written a pretty basic upload script that takes the file and uploads
I have a GWT screen in which i have a file upload bar,whenever i
I have a HTML file upload field from which I'm reading the file name

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.