<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: rfidcard</title>
    <description>The latest articles on Forem by rfidcard (@tm-over).</description>
    <link>https://forem.com/tm-over</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3720633%2Fcd7a15d4-9c22-42a7-8071-6b24a887d44f.png</url>
      <title>Forem: rfidcard</title>
      <link>https://forem.com/tm-over</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/tm-over"/>
    <language>en</language>
    <item>
      <title>Entertainment and Charity Applications</title>
      <dc:creator>rfidcard</dc:creator>
      <pubDate>Thu, 05 Mar 2026 09:23:47 +0000</pubDate>
      <link>https://forem.com/tm-over/entertainment-and-charity-applications-p88</link>
      <guid>https://forem.com/tm-over/entertainment-and-charity-applications-p88</guid>
      <description>&lt;p&gt;The nfc tags vendors Wagga have developed creative applications for both entertainment and social impact. At music festivals, RFID wristband vendors Wagga deploy cashless payment systems that reduce transaction times to under 3 seconds. Simultaneously, the same technology powers charity initiatives where RFID cards manufacturers Wagga enable transparent donation tracking for disaster relief efforts.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
// NFC Reader Implementation Example (120+ lines)
// https://www.tjnfctag.com/nfc-tags-Supplier-Wagga/
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;nfc/nfc.h&amp;gt;

#define MAX_DEVICE_COUNT 8
#define MAX_TARGET_LEN 16
#define MAX_FRAME_LEN 264

typedef struct {
    nfc_device *device;
    nfc_target target;
    uint8_t frame[MAX_FRAME_LEN];
    size_t frame_length;
} NFCReader;

NFCReader* init_nfc_reader() {
    nfc_init(&amp;amp;context);
    if (context == NULL) {
        fprintf(stderr, "Unable to init libnfc (malloc)\n");
        exit(EXIT_FAILURE);
    }

    NFCReader *reader = malloc(sizeof(NFCReader));
    reader-&amp;gt;device = nfc_open(context, NULL);
    if (!reader-&amp;gt;device) {
        fprintf(stderr, "Error opening device\n");
        exit(EXIT_FAILURE);
    }

    nfc_target_init(&amp;amp;reader-&amp;gt;target, NULL, NULL, 0);
    memset(reader-&amp;gt;frame, 0, MAX_FRAME_LEN);
    reader-&amp;gt;frame_length = 0;
    return reader;
}

void configure_reader(NFCReader *reader) {
    if (nfc_initiator_init(reader-&amp;gt;device) &amp;lt; 0) {
        fprintf(stderr, "Cannot configure device\n");
        nfc_close(reader-&amp;gt;device);
        exit(EXIT_FAILURE);
    }

    nfc_target_init(&amp;amp;reader-&amp;gt;target, NULL, NULL, 0);
    printf("NFC reader configured successfully\n");
}

int read_nfc_tag(NFCReader *reader) {
    int result = nfc_initiator_select_passive_target(
        reader-&amp;gt;device, 
        NM_ANY, 
        NULL, 
        0, 
        &amp;amp;reader-&amp;gt;target
    );

    if (result &amp;lt; 0) {
        fprintf(stderr, "Error selecting target\n");
        return -1;
    }

    reader-&amp;gt;frame_length = nfc_target_get_frame(
        &amp;amp;reader-&amp;gt;target, 
        reader-&amp;gt;frame, 
        MAX_FRAME_LEN
    );
    return (reader-&amp;gt;frame_length &amp;gt; 0) ? 0 : -1;
}

void parse_tag_data(NFCReader *reader) {
    if (reader-&amp;gt;frame_length &amp;lt; 16) {
        fprintf(stderr, "Insufficient data length\n");
        return;
    }

    printf("Tag ID: ");
    for (int i = 0; i &amp;lt; 4; i++) {
        printf("%02X ", reader-&amp;gt;frame[i]);
    }
    printf("\n");

    printf("Manufacturer: ");
    switch (reader-&amp;gt;frame[4]) {
        case 0x04: printf("NXP\n"); break;
        case 0x0A: printf("TI\n"); break;
        case 0x12: printf("ST\n"); break;
        default: printf("Unknown\n");
    }

    printf("Data payload:\n");
    for (int i = 8; i &amp;lt; reader-&amp;gt;frame_length; i++) {
        printf("%02X ", reader-&amp;gt;frame[i]);
        if ((i+1) % 16 == 0) printf("\n");
    }
}

void close_nfc_reader(NFCReader *reader) {
    nfc_close(reader-&amp;gt;device);
    nfc_exit(context);
    free(reader);
    printf("NFC reader closed\n");
}

int main(int argc, char *argv[]) {
    NFCReader *reader = init_nfc_reader();
    configure_reader(reader);

    while (1) {
        if (read_nfc_tag(reader) == 0) {
            parse_tag_data(reader);
        } else {
            printf("No tag detected. Try again.\n");
        }
    }

    close_nfc_reader(reader);
    return EXIT_SUCCESS;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Entertaining Applications of NFC</title>
      <dc:creator>rfidcard</dc:creator>
      <pubDate>Tue, 03 Mar 2026 09:01:46 +0000</pubDate>
      <link>https://forem.com/tm-over/entertaining-applications-of-nfc-4dfl</link>
      <guid>https://forem.com/tm-over/entertaining-applications-of-nfc-4dfl</guid>
      <description>&lt;p&gt;NFC technology isn't just for practical applications; it can also be a source of entertainment. One fun way to use NFC is by creating interactive games or experiences. For example, you can program NFC tags to trigger specific actions in a game, such as unlocking new levels or revealing hidden content.&lt;/p&gt;

&lt;p&gt;Here's a simple code example demonstrating how to read an NFC tag using Android's NFC API:&lt;/p&gt;

&lt;p&gt;`import android.nfc.NfcAdapter;&lt;br&gt;
import android.nfc.Tag;&lt;br&gt;
import android.nfc.tech.Ndef;&lt;br&gt;
import android.os.Bundle;&lt;br&gt;
import android.widget.Toast;&lt;br&gt;
import androidx.appcompat.app.AppCompatActivity;&lt;/p&gt;

&lt;p&gt;public class NFCActivity extends AppCompatActivity {&lt;br&gt;
    private NfcAdapter nfcAdapter;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_nfc);

    nfcAdapter = NfcAdapter.getDefaultAdapter(this);
    if (nfcAdapter == null) {
        Toast.makeText(this, "NFC not supported", Toast.LENGTH_SHORT).show();
        finish();
    }
}

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) {
        Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
        if (tag != null) {
            Ndef ndef = Ndef.get(tag);
            if (ndef != null) {
                // Read NDEF message from the tag
                // Process the data as needed
                Toast.makeText(this, "NFC tag detected", Toast.LENGTH_SHORT).show();
            }
        }
    }
}

@Override
protected void onResume() {
    super.onResume();
    if (nfcAdapter != null) {
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
                new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP),
                PendingIntent.FLAG_MUTABLE);
        nfcAdapter.enableForegroundDispatch(this, pendingIntent, null, null);
    }
}

@Override
protected void onPause() {
    super.onPause();
    if (nfcAdapter != null) {
        nfcAdapter.disableForegroundDispatch(this);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;br&gt;
`&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.tjnfctag.com/why-do-i-keep-getting-an-nfc-tag-on-my-phone/" rel="noopener noreferrer"&gt;https://www.tjnfctag.com/why-do-i-keep-getting-an-nfc-tag-on-my-phone/&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>NFC CARD Java Code Example</title>
      <dc:creator>rfidcard</dc:creator>
      <pubDate>Tue, 24 Feb 2026 07:10:40 +0000</pubDate>
      <link>https://forem.com/tm-over/nfc-card-java-code-example-3f20</link>
      <guid>https://forem.com/tm-over/nfc-card-java-code-example-3f20</guid>
      <description>&lt;p&gt;The following is a Java code example based on the Android platform, which implements the reading and writing functions of NFC tags and fully includes the core logic of NFC chip communication:&lt;/p&gt;

&lt;p&gt;`import android.app.Activity;&lt;br&gt;
import android.content.Intent;&lt;br&gt;
import android.nfc.NfcAdapter;&lt;br&gt;
import android.nfc.Tag;&lt;br&gt;
import android.nfc.tech.Ndef;&lt;br&gt;
import android.nfc.tech.NdefFormatable;&lt;br&gt;
import android.os.Bundle;&lt;br&gt;
import android.widget.Toast;&lt;/p&gt;

&lt;p&gt;public class NFCActivity extends Activity {&lt;br&gt;
    private NfcAdapter nfcAdapter;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    nfcAdapter = NfcAdapter.getDefaultAdapter(this);
    if (nfcAdapter == null) {
        Toast.makeText(this, "デバイスはNFCをサポートしていません", Toast.LENGTH_SHORT).show();
        finish();
    }
}

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
    processNFCTag(tag);
}

private void processNFCTag(Tag tag) {
    // NDEF形式データの読み取りを試行
    Ndef ndef = Ndef.get(tag);
    if (ndef != null) {
        try {
            ndef.connect();
            if (ndef.isConnected()) {
                byte[] payload = ndef.getNdefMessage().getRecords()[0].getPayload();
                String content = new String(payload);
                Toast.makeText(this, "読み取り内容：" + content, Toast.LENGTH_LONG).show();
            }
            ndef.close();
        } catch (Exception e) {
            Toast.makeText(this, "読み取り失敗：" + e.getMessage(), Toast.LENGTH_SHORT).show();
        }
    } else {
        // NDEF形式データの書き込みを試行
        writeNFCTag(tag, "Hello NFC");
    }
}

private void writeNFCTag(Tag tag, String data) {
    NdefFormatable ndefFormat = NdefFormatable.get(tag);
    if (ndefFormat != null) {
        try {
            ndefFormat.connect();
            NdefRecord record = NdefRecord.createTextRecord("en", data);
            NdefMessage message = new NdefMessage(new NdefRecord[]{record});
            ndefFormat.format(message);
            ndefFormat.close();
            Toast.makeText(this, "書き込み成功", Toast.LENGTH_SHORT).show();
        } catch (Exception e) {
            Toast.makeText(this, "書き込み失敗：" + e.getMessage(), Toast.LENGTH_SHORT).show();
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}`&lt;/p&gt;

&lt;p&gt;The following is a complete iOS NFC example code, including read and write functions, suitable for iPhone devices that support NFC (such as iPhone 7 and above):&lt;br&gt;
`import CoreNFC&lt;/p&gt;

&lt;p&gt;class NFCManager: NSObject, NFCNDEFReaderSessionDelegate {&lt;br&gt;
    private var session: NFCNDEFReaderSession?&lt;br&gt;
    private var completion: ((String?) -&amp;gt; Void)?&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;func startReading(completion: @escaping (String?) -&amp;gt; Void) {
    self.completion = completion
    session = NFCNDEFReaderSession(
        delegate: self,
        queue: nil,
        invalidateAfterFirstRead: false
    )
    session?.alertMessage = "iPhoneをNFCタグに近づけてください"
    session?.begin()
}

func readerSession(_ session: NFCNDEFReaderSession, didDetectNDEFs messages: [NFCNDEFMessage]) {
    var result = ""
    for message in messages {
        for record in message.records {
            if let payload = String(data: record.payload, encoding: .utf8) {
                result += payload + "\n"
            }
        }
    }
    completion?(result)
    session.invalidate()
}

func readerSession(_ session: NFCNDEFReaderSession, didInvalidateWithError error: Error) {
    completion?(nil)
    print("NFCセッションエラー: \(error.localizedDescription)")
}

func writeToTag(data: String, completion: @escaping (Bool) -&amp;gt; Void) {
    session = NFCNDEFReaderSession(
        delegate: self,
        queue: nil,
        invalidateAfterFirstRead: true
    )
    session?.alertMessage = "空白のNFCタグにiPhoneを近づけてください"
    session?.begin()

    // タグ検出後の処理
    self.completion = { content in
        if content != nil {
            completion(true)
        } else {
            completion(false)
        }
    }
}

// ビューコントローラでの使用例
func demoNFC() {
    let manager = NFCManager()

    // NFCタグ読み取り
    manager.startReading { content in
        if let content = content {
            print("読み取り内容: \(content)")
        } else {
            print("読み取り失敗")
        }
    }

    // NFCタグ書き込み（物理的な空白タグが必要）
    manager.writeToTag(data: "Hello iOS NFC") { success in
        if success {
            print("書き込み成功")
        } else {
            print("書き込み失敗")
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;// Info.plistに追加:&lt;br&gt;
// NFCReaderUsageDescription&lt;br&gt;
// NFCタグへのアクセスが必要です（データの読み取り/書き込み）&lt;br&gt;
// UISupportedExternalAccessoryProtocols&lt;br&gt;
// &lt;br&gt;
//    com.apple.nfc.reader&lt;br&gt;
// &lt;br&gt;
`&lt;/p&gt;

&lt;p&gt;Technical Support: &lt;a href="https://www.tjnftagging.com" rel="noopener noreferrer"&gt;https://www.tjnftagging.com&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Example of RFID technology code related to Best RFID blocking cards</title>
      <dc:creator>rfidcard</dc:creator>
      <pubDate>Wed, 21 Jan 2026 08:03:08 +0000</pubDate>
      <link>https://forem.com/tm-over/example-of-rfid-technology-code-related-to-best-rfid-blocking-cards-4ei9</link>
      <guid>https://forem.com/tm-over/example-of-rfid-technology-code-related-to-best-rfid-blocking-cards-4ei9</guid>
      <description>&lt;p&gt;RFID Reader Basic Code Example (Using Java as an Example)&lt;br&gt;
The following is a simplified Java code example for RFID reader initialization and tag reading, used to illustrate the basic process of RFID communication:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
import java.io.InputStream;
import java.io.OutputStream;

public class RFIDReaderExample {
    public static void main(String[] args) {
        try {
            // 1. Initialize serial port communication
            CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier("COM1");
            SerialPort serialPort = (SerialPort) portIdentifier.open("RFIDReader", 2000);
            serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);

            // 2. Get input and output streams
            InputStream inputStream = serialPort.getInputStream();
            OutputStream outputStream = serialPort.getOutputStream();

            // 3. Send read command (example command; adjust according to reader model)
            outputStream.write("AT+READTAG".getBytes());

            // 4. Read tag data
            byte[] buffer = new byte[64];
            int bytesRead = inputStream.read(buffer);
            String tagData = new String(buffer, 0, bytesRead).trim();

            // 5. Print tag data
            System.out.println("Tag Data: " + tagData);

            // 6. Close the connection
            serialPort.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The technical principle and code association of RFID blocking card&lt;br&gt;
The core technology of RFID blocking cards (such as VAULTRACARD, Credifence, etc.) is to prevent communication between readers and tags through electromagnetic interference. Its working principle can be analogized as:&lt;/p&gt;

&lt;p&gt;Signal detection: Block the built-in circuit of the card to detect electromagnetic signals (such as 13.56MHz) emitted by the reader/writer.&lt;br&gt;
Interference generation: Block the card from generating interference signals of the same frequency but opposite phase as the reader/writer signal, or reduce signal strength through energy absorption.&lt;br&gt;
Communication interruption: The tag is unable to respond due to the inability to receive a valid signal, thereby preventing data reading.&lt;br&gt;
Code level correlation: If simulating the blocking effect from the perspective of a reader/writer, interference logic can be inserted into the code (for principle explanation only, not actual blocking card implementation):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Simulated RFID blocking card interference (pseudocode)
public class RFIDJammingExample {
    public static void main(String[] args) {
        // Assume the RFID reader is already initialized (same as the previous example)
        try {
            OutputStream outputStream = ...; // Get the output stream
            InputStream inputStream = ...;   // Get the input stream

            // 1. Send a read command to the RFID reader
            outputStream.write("AT+READTAG".getBytes());

            // 2. Simulate blocking: Continuously send interference signals (requires hardware support in reality)
            new Thread(() -&amp;gt; {
                try {
                    while (true) {
                        outputStream.write("JAMMING_SIGNAL".getBytes()); // Interference signal (placeholder)
                        Thread.sleep(10); // Control interference frequency (in milliseconds)
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }).start();

            // 3. Attempt to read the tag (should fail due to interference)
            byte[] buffer = new byte[64];
            int bytesRead = inputStream.read(buffer);
            if (bytesRead == -1) {
                System.out.println("Reading failed due to jamming.");
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Provide technical guidance on related content：&lt;br&gt;
&lt;a href="https://www.tjnfctag.com/best-rfid-blocking-cards/" rel="noopener noreferrer"&gt;https://www.tjnfctag.com/best-rfid-blocking-cards/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Content source: &lt;br&gt;
&lt;a href="https://github.com/tianjunrfid-dotcom/generateRFIDonlinegenerator/releases/tag/RFIDblockingcards" rel="noopener noreferrer"&gt;https://github.com/tianjunrfid-dotcom/generateRFIDonlinegenerator/releases/tag/RFIDblockingcards&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>What happens when rel="nofollow" encounters %00</title>
      <dc:creator>rfidcard</dc:creator>
      <pubDate>Wed, 21 Jan 2026 06:57:49 +0000</pubDate>
      <link>https://forem.com/tm-over/what-happens-when-relnofollow-encounters-00-16n0</link>
      <guid>https://forem.com/tm-over/what-happens-when-relnofollow-encounters-00-16n0</guid>
      <description>&lt;p&gt;In the realm of computers, %00 represents null, meaning there is nothing—it indicates the end point, suggesting that reading should stop here and no further processing is needed. Interestingly, consider a link like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;a href="https://www.buyrfidcard.com/" %00 rel="nofollow"&amp;gt;buy rfid card&amp;lt;/a&amp;gt;

Since many websites automatically add rel="nofollow" to links, 
what if that's the case?

&amp;lt;a href="https://www.buyrfidcard.com/%22 %00"&amp;gt;buy rfid card&amp;lt;/a&amp;gt;

After the first% 22 takes effect, 
the actual situation after the change of% 00 interception is
 as follows (rel="nofollow" automatically increases):

&amp;lt;a href="https://www.buyrfidcard.com/" %00" rel="nofollow"&amp;gt;buy rfid card&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgp2e2oosp5t6babjzlen.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgp2e2oosp5t6babjzlen.jpg" alt=" " width="800" height="166"&gt;&lt;/a&gt;&lt;br&gt;
 Will the rel="nofollow" attribute still take effect? It's not hard to find that when using AI or online search engines to seek answers, different opinions emerge. According to the official statements from search engines, the conclusion is that it depends on whether the server allows %00 to take effect. So, what are your new interpretations on this matter?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/tianjunrfid-dotcom/generateRFIDonlinegenerator/releases/tag/%2500" rel="noopener noreferrer"&gt;https://github.com/tianjunrfid-dotcom/generateRFIDonlinegenerator/releases/tag/%2500&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>PHP file upload example!</title>
      <dc:creator>rfidcard</dc:creator>
      <pubDate>Tue, 20 Jan 2026 03:41:06 +0000</pubDate>
      <link>https://forem.com/tm-over/php-file-upload-example-3nda</link>
      <guid>https://forem.com/tm-over/php-file-upload-example-3nda</guid>
      <description>&lt;p&gt;watched &lt;br&gt;
&lt;a href="https://dev.to/einlinuus/how-to-upload-files-with-php-correctly-and-securely-1kng"&gt;https://dev.to/einlinuus/how-to-upload-files-with-php-correctly-and-securely-1kng&lt;/a&gt; I think this post is written very interestingly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7u9ecbm3zpkzaqnoy723.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7u9ecbm3zpkzaqnoy723.png" alt=" " width="800" height="726"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbj9ku65euhaztn5387sv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbj9ku65euhaztn5387sv.png" alt=" " width="776" height="532"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw8zaqs4oh5d1r246jhr2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw8zaqs4oh5d1r246jhr2.png" alt=" " width="800" height="779"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F13yr54x4jlxgw1yxbilh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F13yr54x4jlxgw1yxbilh.png" alt=" " width="760" height="719"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It may be safer to do so in the following way&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Document&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;!-- Part from this tutorial --&amp;gt;
    &amp;lt;form method="post" action="upload.php" enctype="multipart/form-data"&amp;gt;
        &amp;lt;input type="file" name="myFile" /&amp;gt;
        &amp;lt;input type="submit" value="Upload"&amp;gt;
    &amp;lt;/form&amp;gt;
    &amp;lt;!-- End of part from this tutorial --&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;

&amp;lt;?php

if (!isset($_FILES["myFile"])) {
    die("There is no file to upload.");
}

$filepath = $_FILES['myFile']['tmp_name'];
$fileSize = filesize($filepath);
$fileinfo = finfo_open(FILEINFO_MIME_TYPE);
$filetype = finfo_file($fileinfo, $filepath);

if ($fileSize === 0) {
    die("The file is empty.");
}

if ($fileSize &amp;gt; 3145728) { // 3 MB (1 byte * 1024 * 1024 * 3 (for 3 MB))
    die("The file is too large");
}

$allowedTypes = [
   'text/x-php' =&amp;gt; 'php',
   'image/png' =&amp;gt; 'png',
   'image/jpeg' =&amp;gt; 'jpg'
];

if (!in_array($filetype, array_keys($allowedTypes))) {
    die("File not allowed.");
}

$filename = basename($filepath); // I'm using the original name here, but you can also change the name of the file here
$extension = $allowedTypes[$filetype];
$targetDirectory = __DIR__ . "/uploads"; // __DIR__ is the directory of the current PHP file

$newFilepath = $targetDirectory . "/" . $filename . "." . $extension;

if (!copy($filepath, $newFilepath)) { // Copy the file, returns false if failed
    die("Can't move file.");
}
unlink($filepath); // Delete the temp file

echo "File uploaded successfully :)";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>php</category>
      <category>security</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
