cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close

Discuss Dropbox Developer & API

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted

Upload File not working through API

Helpful | Level 5

I have an issue and can't figure out what's going on.  If I run this code:

if ( empty( $_FILES['the_upload'] ) ) {
    ?>
    <form enctype="multipart/form-data" method="POST" action="">
        <p>
            <label for="file">Upload File</label>
            <input type="file" name="the_upload"/>
        </p>
        <p><input type="submit" name="submit-btn" value="Upload!"></p>
    </form>
<?php } else {

    $upload_name = $_FILES["the_upload"]["name"];
    echo "<pre>";
    echo "\n\n<b>Uploading $upload_name:</b>\r\n";
    $meta = $dropbox->UploadFile( $_FILES["the_upload"]["tmp_name"], $upload_name );
    print_r( $meta );
    echo "\r\n done!";
    echo "</pre>";
}

I get a form, select my file and click Upload and it uploads the file to my dropbox without issues; however, if I run this code:

  $upload_name = 'File_000.jpeg';
    echo "<pre>";
    echo "\n\n<b>Uploading $upload_name:</b>\r\n";
    $meta = $dropbox->UploadFile( '/Users/Shared/test', $upload_name );
    print_r( $meta );
    echo "\r\n done!";
    echo "</pre>";

The file uploads to my dropbox; however, it has 0 bytes and isn't really uploading the file.  Any ideas on what could be the issue?

Thanks in advance!
Jordon

1 Accepted Solution

Accepted Solutions
Highlighted

Re: Upload File not working through API

Helpful | Level 5

Nevermind, I figured this out.  I tried deleting this post, but didn't see the option.

 

[CLOSED BY COMMUNITY'S MODERATORS AS PER USER'S REQUEST]

View solution in original post

1 Reply 1
Highlighted

Re: Upload File not working through API

Helpful | Level 5

Nevermind, I figured this out.  I tried deleting this post, but didn't see the option.

 

[CLOSED BY COMMUNITY'S MODERATORS AS PER USER'S REQUEST]

View solution in original post

Polls
Do you know how to organize your files and folders?
We have created a guide on folder best practice, so you can get organized now check it out here.

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?