Jump to content

Provide Link to Uploaded File


Warptweet

Recommended Posts

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
Link to comment
Share on other sites

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?
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

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']?
Link to comment
Share on other sites

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?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.