简体   繁体   English

在另一个域中上传文件

[英]Upload file in another domain

i have form that provides upload mp3 and give .mp3 link 我有提供上传mp3并提供.mp3链接的表格

<form action="https://upload.clyp.it/upload" enctype="multipart/form-data" method="post">
    <input type="file" name="audioFile">
    <input type="submit" value="Send to Clyp">
</form>

api link: https://clyp.it/api api链接: https//clyp.it/api

i want to insert this form in my website, upload mp3 and then save link in my database. 我想将此表格插入我的网站,上传mp3,然后将链接保存在我的数据库中。 problem is that after upload it redirects. 问题是上传后重定向。 i tried ajax upload but not works, it gives me cross origin error. 我尝试了ajax上传,但是无法正常工作,它给了我跨源错误。 i also tried upload with curl but not works. 我也尝试了卷曲上传,但没有用。 any idea? 任何想法?

You need to allow cross origin on ur PHP code ... use this in the PHP code where you are uploading the File to. 您需要允许您的PHP代码上的跨源代码...在将文件上传到的PHP代码中使用此代码。 It should Help 它应该帮助

header('Access-Control-Allow-Origin: *');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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