第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何將 php 變量的值復制到用戶的剪貼板

如何將 php 變量的值復制到用戶的剪貼板

Helenr 2023-10-17 17:02:50
我已經嘗試過將我上傳的圖像復制到用戶的剪貼板,但圖像正在上傳,并且其地址在上傳后顯示,但我也需要將其地址復制到用戶的剪貼板`<?php//upload.phpif($_FILES["file"]["name"] != ''){ $test = explode('.', $_FILES["file"]["name"]); $ext = end($test); $name = rand(100, 999) . '.' . $ext; $location = './upload/' . $name;  $url= 'http://i.com/upload/' . $name; move_uploaded_file($_FILES["file"]["tmp_name"], $location); echo '<img src="'.$location.'" height="150" width="225" class="img-thumbnail" />'; echo "\n\n\n\n$url";<!DOCTYPE html><html><body><p>Click on the button to copy the text from the text field. Try to paste the text </p><input type="text" value="$url" id="myInput"><button onclick="myFunction()">Copy text</button><script>      function myFunction() {  var copyText = document.getElementById("myInput");  copyText.select();  copyText.setSelectionRange(0, 99999)  document.execCommand("copy");  alert("Copied the text: " + copyText.value);}</script></body></html>}?>`
查看完整描述

1 回答

?
蠱毒傳說

TA貢獻1895條經驗 獲得超3個贊

這應該適合你:


<script>

function myFunction() {

    let inputEl = document.getElementById("myInput");

    inputEl.select();                                    // Select element

    inputEl.setSelectionRange(0, inputEl.value.length); // select from 0 to element length


    const successful = document.execCommand('copy');   // copy input value, and store success if needed


    if(successful) {

        alert("Copied the text: " + inputEl.value);

    } else {

        // ...

    }

}

</script>

編輯:澄清并修復其他一些小錯誤:


<?php

    //upload.php

    if($_FILES["file"]["name"] != '')

    {

        $test = explode('.', $_FILES["file"]["name"]);

        $ext = end($test);

        $name = rand(100, 999) . '.' . $ext;

        $location = './upload/' . $name; 

        $url= 'http://i.com/upload/' . $name;


        move_uploaded_file($_FILES["file"]["tmp_name"], $location);

        echo '<img src="'.$location.'" height="150" width="225" class="img-thumbnail" />';


        echo "\n\n\n\n$url";

    } else {

        $url = "";

    }

?>


<!DOCTYPE html>

<html>

<head>

    <title>example title</title>

</head>


<body>

    <p>Click on the button to copy the text from the text field. Try to paste the text </p>


    <input type="text" value="<?php echo $url; ?>" id="myInput">

    <button onclick="myFunction()">Copy text</button>


    <script>

    function myFunction() {

        let inputEl = document.getElementById("myInput");

        inputEl.select();                                    // Select element

        inputEl.setSelectionRange(0, inputEl.value.length); // select from 0 to element length


        const successful = document.execCommand('copy');   // copy input value, and store success if needed


        if(successful) {

            alert("Copied the text: " + inputEl.value);

        } else {

            // ...

        }

    }

    </script>

</body>

</html>


查看完整回答
反對 回復 2023-10-17
  • 1 回答
  • 0 關注
  • 110 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號