Jump to content

Recommended Posts

Why do I get error on move or copy?

<?php
$user = "joe";mkdir("members/$user", 0777);$srcfile='images/we.png';
$dstfile='members/$user/we.png';
$moveResult = move_uploaded_file($srcfile, $dstfile);
if ($moveResult != true) {echo 'failed';exit();}//copy($srcfile, $dstfile) or die("Unable to copy $srcfile to $dstfile.");
echo $srcfile, $dstfile, '?/';

?>
Link to comment
https://forums.phpfreaks.com/topic/279159-php-move/
Share on other sites

I am trying to copy a default avatar pic to a users folder which is generated during activation The above code generates the folder I want to copy the default avatar to that folder in the users profile This is the activation code I just need the copy syntax..

<?php
if(isset($_GET['user']) && $_GET['user'] != "" && isset($_GET['token']) && $_GET['token'] != ""){
    include_once("scripts/connect.php");
    $user = preg_replace('#[^0-9]#', '', $_GET['user']);
    $token = preg_replace('#[^a-z0-9]#i', '', $_GET['token']);
    $stmt = $db->prepare("SELECT user, token FROM activate WHERE user=:user AND token=:token LIMIT 1");
    $stmt->bindValue(':user',$user,PDO::PARAM_INT);
    $stmt->bindValue(':token',$token,PDO::PARAM_STR);
    try{
        $stmt->execute();
        $count = $stmt->rowCount();
        if($count > 0){
            try{
                $db->beginTransaction();
                $updateSQL = $db->prepare("UPDATE members SET activated='1' WHERE id=:user LIMIT 1");
                $updateSQL->bindValue(':user',$user,PDO::PARAM_INT);
                $updateSQL->execute();
                $deleteSQL = $db->prepare("DELETE FROM activate WHERE user=:user AND token=:token LIMIT 1");
                $deleteSQL->bindValue(':user',$user,PDO::PARAM_INT);
                $deleteSQL->bindValue(':token',$token,PDO::PARAM_STR);
                $deleteSQL->execute();
                if(!file_exists("members/$user")){
                    mkdir("members/$user", 0755);
                }
                $db->commit();
                echo 'Your account has been activated! Click the link to log in: <a href="login.php">Log In</a>';
                $db = null;
                exit();
            
            }
            catch(PDOException $e){
                $db->rollBack();
                echo $e->getMessage();
            }
        }else{
            echo "Sorry, There has been an error. Maybe try registering again derp.";
            $db = null;
            exit();
        }
    }
    catch(PDOException $e){
        echo $e->getMessage();
        $db = null;
        exit();
    }
}
?>
Edited by cabbie
Link to comment
https://forums.phpfreaks.com/topic/279159-php-move/#findComment-1436011
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.