php - How to go prevent a song from uploading if the query fails and vice versa? -


i have music application user uploads , song , song information added mysql database. right stands script takes song, renames it, , uploads server. after done takes renamed song , additional information passed form , queries database. there way prevent either action happening if either fails? right if upload fails query not run if upload works , query fails option delete song uploaded every time happens? might not possible , didn't post code because i'm looking idea not fix. thanks.

you can send ajax request server run query. if query succeeds can start upload. if fails, upload wont start.

if succeeds, can retrieve inserted id of database entry , put in hidden field on page. start upload of file , include inserted id in request. if upload files whatever reason, remove id database.

note: sure run sorts of security checks id.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -