Warptweet Posted January 13, 2007 Share Posted January 13, 2007 When a user uploads a file to my website, it of course, uploads.Although, I also use a code to create a .php file.How can I make it so that using either HTML or PHP that it created a link like <a href="??????">link here</a> to the file that was uploaded? That way users can easily click a link to any uploaded file, any help?The file is uploaded to the /uploads directory, so would it be like this?<a href=$_FILES>Watch this Flash!</a> or something like that? Please and thanks :D Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted January 13, 2007 Share Posted January 13, 2007 you want to make a text link instead of a submit button to upload the files???Ted Quote Link to comment Share on other sites More sharing options...
Warptweet Posted January 13, 2007 Author Share Posted January 13, 2007 No.Once my file is uploaded to my website, it is now on my website.Although, I need a way for my visitors to SEE the uploaded files.In this code, I have a code that created a .php file using fopen()Now, I use fwrite() to write PHP or HTML code to the .php file I just created.What code would I use to add a link directly to the file that was uploaded? Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted January 13, 2007 Share Posted January 13, 2007 so what you want to do is to give a link to your visitors of the file they just uploaded?Ted Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 13, 2007 Share Posted January 13, 2007 link to it like you would to a page on your site. Like<a href="/uploads/filenamehere">Link</a>When you're uploading it, you'll need to get the name of it and save it somehow so you know what the link should be. Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted January 13, 2007 Share Posted January 13, 2007 If you want to echo it on the same page, after your upload script just put:[code]echo "<a href=\"uploads/$filename\">Link</a>";//where $filename is the name of the file you just stored,[/code]however if on a different page:[code]header("location: page.php?filename=$filename");[/code]and on your next page, put:[code]$filename = $_GET['filename'];echo "<a href=\"uploads/$filename\">Link</a>";//where $filename is the name of the file you just stored,[/code] Quote Link to comment Share on other sites More sharing options...
Warptweet Posted January 13, 2007 Author Share Posted January 13, 2007 Thanks for trying, but could you please explain that a bit more?Okay, my visitors submit a flash .swf file to my uploader.To process the form, it uses processupload.php.On the SAME code as processupload.php as it proceses the upload, it creates a file with a .php extension.Now, I need it so that the file that is created have a code written in it that gives a link to the file that was created. Does anyone know how I can get the location of the file that was uploaded? Isn't it something like $_FILES['file']? Quote Link to comment Share on other sites More sharing options...
Warptweet Posted January 13, 2007 Author Share Posted January 13, 2007 I think I understand teds example, now I have a different problem.How can I make $filename the name of the file that was uploaded? And the direct link too, as I think simply putting the variable would make some serious mistakes. So maybe how can I store the direct link to the uploaded file and make it link to that in an HTML or PHP code? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.