Linking Uploaded File in Phpmailer - mysql

I'm trying to store links to files uploaded with phpmailer in my MySQL database so that when a web page calls the record, the user can download the files.
My files were getting attached as I want before I added the anchor tag. Now they no longer get attached to the email, and only the file names are making it into the database. Am I missing something simple?
$mail->AddAttachment("<a href='/home/company/upload/'>".$_FILES['rfile']['name'][0]."</a>"); // add attachments
$mail->AddAttachment("<a href='/home/company/upload/'>".$_FILES['rfile']['name'][1]."</a>"); // add attachments

Why are you putting HTML into something that's expecting a path to a file? Do this instead (and pay attention to what Marc B said - you should be calling move_uploaded_file() somewhere.).
$mail->AddAttachment('/home/company/upload/'.$_FILES['rfile']['name'][0]);
$mail->AddAttachment('/home/company/upload/'.$_FILES['rfile']['name'][1]);

Related

Uploaded folder of images to Pinata (IPFS) but the URL structure is coming back strange

Im trying to create some NFTs. I've done this before and im familiar with the process but never encountered this issue before. I uploaded a folder of images, so I can include the CID in my metadata (.JSON files). For some reason when I click on files in the folder I uploaded on Pinata its adding characters to the URL that should not be there
Expected Result: https://gateway.pinata.cloud/ipfs/[CID]/1.png
What im getting: https://gateway.pinata.cloud/ipfs/[CID]/%201.png
Pinata/IPFS keeps appending "%20" to the beginning of my file names in the folder rather than just leaving it as "1.png"
Does anyone know what might be going on? I've tried deleting and re-uploading my files several times
This means your files have a leading space. This can happen if you programmatically created it (easy to accidentally add a space in your file name).
%20 is the url encoding for a space: https://www.w3schools.com/tags/ref_urlencode.ASP

Node.js/Express.js - How to render a remote HTML file to the client?

I am currently in the process of making a blog website, writers for this website have the ability to upload AMP HTML files and the assets required for does files to work. Both the html file and their assets get sent to our CDN.
Now, when a client visits the website in the link example.com/13215 the server gets the parameter 13215 and checks what post it refers to in the database and retrieves the link to the HTML file. How can I send this HTML file to the front end with Node.js/Express.js even though it is a remote file.
Just copy pasting the URL into response.sendFile() and response.render() functions just throws errors. I thought about reading the file contents then writing them to a file then sending them to the client but I don't think that's a good idea performance wise.
Is there a way to achieve this?

JSP File Upload

In my jsp page, I need to upload files, images, Word Documents, Excel sheets, Etc. using a single upload option.
After uploading, I want to place them in a folder which has to be created in user's name(If not exists) within root folder.
Also I need to rename the file into some string like username+serial number.
I should be able to give links to these files for displaying them.
I am new to jsp. please help me.
This tutorial should help you: http://www.roseindia.net/jsp/file_upload/Sinle_upload.xhtml.shtml

Can I upload a file to my server using a form and POST in HTML?

I want to create a way that people can upload images to an images folder on my server using an HTML form and the input type file, I thought that the only way it was ever possible to add a file to my server was to FTP in there and drag it in. Is there a straight forward way I could create a form that would allow someone to select an image and just upload it to my folder?
Pretty straight forward example from w3schools. Comes with an example HTML and PHP script
http://www.w3schools.com/php/php_file_upload.asp
See POST method uploads for an introduction. There are plenty of file upload examples on Google.
You could find more information here : http://www.php.net/manual/en/features.file-upload.post-method.php
You are going to need some type of script on the server to handle the file. I know that you can google for and find at least a couple of PHP scripts because I had to do it a few years ago. The script can also be useful in that it can change the name of the file so that duplicate files do not overwrite each other.
Sample upload script

A web-page that would provide a user to download a certain file from it, but would not disclose the location of that file - is it possible at all?

(I am sorry if my question is not in the right place. (I've been thinking for awhile and came up to the conclusion that this one is the best place for my question)
Is it possible to create such an HTML web-page that would provide a user to download a certain file from it, but would not disclose the location of that file (i.e. the user would not know the URL of the file that he is downloading).
If yes, would you, please, give me some directions as to which HTML code I should use to create such a page.
The HTML page would provide a link to a server side script passing a filename or other unique moniker:
Download Now
The script would read the identifier, derive a full path from it, load the file and write it back with the appropriate headers/mime type causing the browser to prompt the user with the normal download dialog.
The only location data available to the user would be the link to the script - which would - unless you add some security - serve back the file just as if it were a standard url pointing to a file.
(PHP Example)
With pure html, no. But with a serverside script (php, c#, vb, perl, or other) yes. You would stream the file to user. In that case just the serverside script has access to the origin files