note 78015 added to function.move-uploaded-file
| From: | steviedifranco at ohioconnect dot net | Date: | Mon, 24 Sep 2007 15:34:55 +0000 |
| Subject: | note 78015 added to function.move-uploaded-file | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-130744@lists.php.net to get a copy of this message | ||
If you are handling a file upload with move_uploaded_file and you want to get the file extension,
I've seen examples using 'explode()', but you may run into problems if the file uses
a period in the name.
For example, if the uploaded file name is "this.video.file.mpg" and if you do an
explode(), you'll get an array of 4 different values.
To be safe, do a substr_count() ahead of the explode(), like this:
$uploadedFileName = $_FILES['videoFile']['name'] ;
$periodNum = substr_count($uploadedFileName, '.') ;
$uploadedExplode = explode('.', $uploadedFileName) ;
$fileExtension = $uploadedExplode[$periodNum] ;
----
Server IP: 69.147.83.197
Probable Submitter: 76.188.114.22
----
Manual Page -- http://www.php.net/manual/en/function.move-uploaded-file.php
Edit -- https://master.php.net/note/edit/78015
Del: integrated -- https://master.php.net/note/delete/78015/integrated
Del: useless -- https://master.php.net/note/delete/78015/useless
Del: bad code -- https://master.php.net/note/delete/78015/bad+code
Del: spam -- https://master.php.net/note/delete/78015/spam
Del: non-english -- https://master.php.net/note/delete/78015/non-english
Del: in docs -- https://master.php.net/note/delete/78015/in+docs
Del: other reasons-- https://master.php.net/note/delete/78015
Reject -- https://master.php.net/note/reject/78015
Search -- https://master.php.net/manage/user-notes.php