Jump to content

php move


cabbie

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();
    }
}
?>
Link to comment
https://forums.phpfreaks.com/topic/279159-php-move/#findComment-1436011
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.