2016-11-16 3 views
1

PHPを使用してあるフォルダから別のフォルダに画像をコピーしようとしています。 画像はうまく動いていますが、画像を開くときに画像が表示されません。あるフォルダから別のフォルダにコピー中に画像が表示されない

アイデア?

ありがとうございます。

以下は私のコードです。

if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'image_copy') { 
    $image = $_POST['image']; 
    //name of file to be copied 
    $img = $image; 
    //read the file 
    $fp = fopen('files/post/' . $img, 'r') or die("Could not contact $img3"); 
    $page_contents = ""; 
    $new_text = fread($fp, 100); 
    $page_contents = $new_text; 
    //This moves you from the current directory user to the images directory in the new user's directory 
    chdir("files/profile"); 
    //name of your new file 
    $newfile = $image; 
    //create new file and write what you read from old file into it 
    $fd = fopen($newfile, 'w'); 
    fwrite($fd, $page_contents); 
    //close the file 
    fclose($fd); 
    exit; 
} 
+0

あなたが使用している ''のHTMLコードを表示することはできますか? – Abela

+0

オクラホマ@Abela – sradha

答えて

0

私は、ファイルがコンテンツを取得し、コンテンツを入れて使用してそれを他の方法を作りました。

$image = $_POST['image']; 
    $dir_to_save = "files/profile/"; 
    if (!is_dir($dir_to_save)) { 
     mkdir($dir_to_save); 
    } 
    file_put_contents($dir_to_save . $image, file_get_contents('files/post/' . $image)); 

しかし、私は、PHPの移動方法で行うことができません。

+0

この回答を削除して質問を更新してください。 –

関連する問題