简体   繁体   中英

MySQL / PHP Drag and Drop File Upload

I am looking to upload files into a MySQL database using a drag and drop application. Any ideas?

I want to be able to drag a file into the browser and then type in a file name.

THANKS!

The Java Jump Loader will allow you to drag files into your browser. Getting them referenced in a MySQL table will be a different job though. You'll have to run that query from the server-side.

The Jump Loader documentation even has code examples demonstrating how to move the file once it's uploaded to your permanent location. Inserting the file-reference into the database is a breeze from there.

Essentially, you'll just run an INSERT query containing the filepath:

$sql = "INSERT INTO files(filepath) VALUES('%s')";
$rst = mysql_query( sprintf($sql, $filepath) ) or die( mysql_error() );

And if you need to you can spit out the newly created ID:

print mysql_insert_id();

For a demo of drag-and-drop uploading, visit http://jumploader.com/demo_embedded.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM