Xin chào các bạn cũng muốn thêm vào cách sao chép bằng cách sao chép và dán động.
giả sử chúng ta không biết thư mục thực tế mà người dùng sẽ tạo nhưng chúng ta biết trong thư mục đó chúng ta cần sao chép các tập tin, để kích hoạt một số chức năng như xóa, cập nhật, xem, v.v.
bạn có thể sử dụng một cái gì đó như thế này ... Tôi đã sử dụng mã này trong một trong những dự án phức tạp mà tôi hiện đang bận rộn. tôi chỉ tự xây dựng nó vì tất cả các câu trả lời tôi nhận được trên internet đều gây ra lỗi cho tôi.
$dirPath1 = "users/$uniqueID"; #creating main folder and where $uniqueID will be called by a database when a user login.
$result = mkdir($dirPath1, 0755);
$dirPath2 = "users/$uniqueID/profile"; #sub folder
$result = mkdir($dirPath2, 0755);
$dirPath3 = "users/$uniqueID/images"; #sub folder
$result = mkdir($dirPath3, 0755);
$dirPath4 = "users/$uniqueID/uploads";#sub folder
$result = mkdir($dirPath4, 0755);
@copy('blank/dashboard.php', 'users/'.$uniqueID.'/dashboard.php');#from blank folder to dynamic user created folder
@copy('blank/views.php', 'users/'.$uniqueID.'/views.php'); #from blank folder to dynamic user created folder
@copy('blank/upload.php', 'users/'.$uniqueID.'/upload.php'); #from blank folder to dynamic user created folder
@copy('blank/delete.php', 'users/'.$uniqueID.'/delete.php'); #from blank folder to dynamic user created folder
Tôi nghĩ rằng facebook hoặc twitter sử dụng một cái gì đó như thế này để xây dựng mỗi bảng điều khiển người dùng mới năng động ....
copy( 'foo/test.php', 'bar/test.php' )
tạobar
thư mục nếu nó không tồn tại?