note 126207 added to function.pathinfo

From: Date: Thu, 01 Jul 2021 04:44:51 +0000
Subject: note 126207 added to function.pathinfo
Groups: php.notes 
Request: Send a blank email to php-notes+get-216564@lists.php.net to get a copy of this message
When you need to get the file extension to upload a file with a <form> POST method, try this way: // $_FILES['archivo'] receives the <input> file (named 'archivo'), ['name'] gets the file name. $nombre = $_FILES['archivo']['name']; //['tmp_name] gets the temporal name of the file (not the real name), which will be used later $nombre_temporal = $_FILES['archivo']['tmp_name']; //Here is the magic of pathinfo to get the file extension $extension = pathinfo($nombre, PATHINFO_EXTENSION); $nombre_final = $nombre. ".". $extension; // $ruta is where you want to save the file $ruta = "subidos/".$nombre_final; move_uploaded_file($nombre_temporal, $ruta); ---- Server IP: 45.112.84.4 Probable Submitter: 45.112.85.242 (proxied: 2806:10ae:6:546:5184:e71b:86d3:7c8e) ---- Manual Page -- https://php.net/manual/en/function.pathinfo.php Edit -- https://main.php.net/note/edit/126207 Del: integrated -- https://main.php.net/note/delete/126207/integrated Del: useless -- https://main.php.net/note/delete/126207/useless Del: bad code -- https://main.php.net/note/delete/126207/bad+code Del: spam -- https://main.php.net/note/delete/126207/spam Del: non-english -- https://main.php.net/note/delete/126207/non-english Del: in docs -- https://main.php.net/note/delete/126207/in+docs Del: other reasons-- https://main.php.net/note/delete/126207 Reject -- https://main.php.net/note/reject/126207 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#216564) next »