PHP kullanarak bir dosyayı yükleme

0 Cevap php

PHP bir API kullanarak kendi sunucusundan soundcloud.com bir dosya yükleyerek am:

if (isset($mime)) {
        $tmp_file = $tmp_path . $_FILES['file']['name'];

        // Store the track temporary.
        if (move_uploaded_file($_FILES['file']['tmp_name'], $tmp_file)) {
            $post_data = array(
                'track[title]' => stripslashes($_POST['title']),
                'track[asset_data]' => realpath($tmp_file),
                'track[sharing]' => 'private'
            );

            if ($response = $soundcloud->upload_track($post_data, $mime)) {
                $response = new SimpleXMLElement($response);
                $response = get_object_vars($response);
                $message = 'Success! <a href="' . $response['permalink-url'] . '">Your track</a> has been uploaded!';

                // Delete the temporary file.
                unlink(realpath($tmp_file));
            } else {
                $message = 'Something went wrong while talking to SoundCloud, please try again.';
            }
        } else {
            $message = 'Couldn\'t move file, make sure the temporary path is writable by the server.';
        }
    } else {
        $message = 'SoundCloud support .mp3, .aiff, .wav, .flac, .aac, and .ogg files. Please select a different file.';
    }
}

This is my code. The temp path is http://122.166.23.38/dev3/bids4less/funkeymusic/upload and it has permissions 777 (-rwxrwxrwx).

Ama gösterir:

Dosyayı hareket edemiyordu, geçici yol sunucu tarafından yazılabilir olduğundan emin olun.

Ben bu sorunu nasıl düzeltebilirim?

0 Cevap