php ajax file uploader

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
jsrds
-


Joined: 30 Dec 2014
Posts: 1
Location: Sri Lanka

PostPosted: Tue Dec 30, 2014 2:34 pm    Post subject: php ajax file uploader Reply with quote

Hi!

I have been facing an issue with php ajax File uploader that has the drag drop area to drop Files and then it uploads. It is changing the File Extension to none when uploads to server. any body can help?
_________________
JOSEPH S R DE SARAM
CISSP FBCS CITP MSCS MACS Snr CP SAP FI SAP BW
Back to top View user's profile Send private message Visit poster's website AIM Address
badai
-


Joined: 24 Apr 2003
Posts: 82

PostPosted: Wed Feb 18, 2015 5:36 pm    Post subject: Reply with quote

i think that's what php do, use random string to name the temp file. you can easily rename it to anything you want.
Back to top View user's profile Send private message
Toasty
-


Joined: 21 Feb 2008
Posts: 298
Location: Chicago, IL

PostPosted: Wed Dec 16, 2015 5:42 pm    Post subject: Reply with quote

The original file name is in $_FILES['yourfieldname']['name']

The temporary file is in $_FILES['yourfieldname']['tmp_name']

So grab the extension off the first one:

Code:

<?php

$fileName = $_FILES['yourfieldname']['name'];
$extension = array_pop(explode('.',$fileName));

echo $extension;

_________________
Audit the secure configuration of your server headers!
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group