How to Writing Image Upload PHP Script [w/ subs]



00:00:00 – let me ck we are going to create image
00:00:02 – upload PHP screen which will accept
00:00:04 – image sent to us by mobile application
00:00:07 – and will record this image will store it
00:00:10 – on our server side into a web folder
00:00:14 – okay so i will i have minded been
00:00:17 – developed an environment open i will go
00:00:19 – to scripts folder and will create PHP
00:00:22 – file and i will call it in each upload
00:00:28 – you
00:00:30 – ok so our mobile application will send
00:00:33 – this two pieces of information one piece
00:00:36 – of information is going to be user ID
00:00:39 – and we will need to read it from post a
00:00:44 – special type array which will be
00:00:47 – populated with HTTP parameters I'm sent
00:00:51 – to us with an HTTP request so one of
00:00:55 – those HTTP parameters it will be user ID
00:00:57 – and because I'm we are going to store
00:01:05 – our image locally on web server we need
00:01:08 – to provide we need to create a target
00:01:12 – directory so I will be clearly one I
00:01:14 – don't call it on target directory and to
00:01:20 – identify its back on my web server is
00:01:24 – stored and applications some HD box
00:01:30 – clearly the application Sam HD box and
00:01:36 – then project name and then under
00:01:38 – projects mean there will be a folder I
00:01:41 – can call it profile pictures or found
00:01:46 – pictures or this folder can be created
00:01:50 – by using HP code if it does not exist
00:01:52 – and under profile pictures will be
00:01:54 – storing user profile so i will you go
00:01:59 – and copy on this
00:02:04 – you
00:02:07 – this flash perform pictures and pictures
00:02:18 – and under those / file pictures will
00:02:22 – create a new folder and with the name
00:02:24 – user ID and user ID will come to us from
00:02:30 – an HTTP request ok so far next if this
00:02:34 – guy vector it does not exist obviously
00:02:37 – we will not have a directory with the
00:02:40 – name like user ID for one user is going
00:02:44 – to be one for another it will be two for
00:02:47 – user ID for the user with user ID three
00:02:50 – is going to be profile pictures / 3 so
00:02:53 – we will need some create of this
00:02:57 – directors and here's a little HP code
00:02:59 – that will allow us to use file exists a
00:03:02 – special type PHP function which will
00:03:04 – return true or false so if this
00:03:07 – directory does not exist it will count
00:03:09 – in and then we will use PHP function and
00:03:12 – guide in which will create a directory
00:03:14 – and we'll give it permission so that
00:03:17 – time of HP script can write to it okay
00:03:22 – next we will need to append to our
00:03:25 – directory file name of the image and
00:03:28 – file name will be incentive to ask for
00:03:31 – mobile app and enroll used for special
00:03:34 – type III function which is called
00:03:36 – basting and basting will return as a
00:03:39 – trailing name of the phone trilling file
00:03:43 – name of the pot so it will pick the file
00:03:46 – name and will concatenate it to
00:03:48 – Detective directories separated would be
00:03:51 – /o k and next we'll need to unload
00:03:57 – loaded file into the target directory
00:04:02 – and again we are going to use a note
00:04:04 – uploaded file special type which a
00:04:06 – function which will take which will make
00:04:09 – necessary checks that file name is ok
00:04:12 – and the file is uploaded and we'll move
00:04:17 – from 6-10 planning to target director
00:04:20 – and if you look up enter HP
00:04:23 – documentation I have a move uploaded
00:04:26 – file function open here and save the
00:04:29 – definition move uploaded file kate moss
00:04:31 – and uploaded file into a new location
00:04:34 – and this function checks to ensure that
00:04:37 – the file is ignited by file mean the one
00:04:41 – that comes from the temple one is bound
00:04:44 – upload file and if it's well it will be
00:04:49 – moved to a file name given by
00:04:52 – destination ok so we have it here and if
00:04:58 – file is moved successfully then we can
00:05:00 – send back I go back to mobile
00:05:03 – application adjacent response and the
00:05:07 – way thank you I de klerk HP array in
00:05:10 – that PHP array I store I create message
00:05:14 – key with the value file with the
00:05:17 – filename has been uploaded in the status
00:05:20 – ok and I also happened user ID so as
00:05:23 – mobile application just gets to user ID
00:05:26 – as a confirmation that for this user
00:05:28 – file image head was uploaded
00:05:31 – successfully otherwise if file could not
00:05:34 – be uploaded could not be moved in to
00:05:37 – attack you directly we will echo back to
00:05:39 – Jason encoded message and again this is
00:05:43 – a PHP array I create an HP array inside
00:05:46 – of those Jason got it and then i create
00:05:49 – HP arrangement asset into JSON encode HP
00:05:53 – function and the content of this PHP
00:05:56 – array here is a similar message key
00:05:58 – status key and user ID of the message
00:06:01 – this time is different so it is an error
00:06:04 – uploading the file ok so this is a
00:06:08 – simple but very important of HP screen
00:06:11 – which will arm except user Amy from HTTP
00:06:16 – POST and the file from are coming from
00:06:19 – our files again special type on array HP
00:06:25 – array which will contain filename that
00:06:28 – mobile
00:06:29 – kitchen centers and it will record it to
00:06:32 – the target destination to the folder
00:06:34 – that we are specified okay so this is it
00:06:39 – and we can go back to our mobile
00:06:41 – application and prepare script advil on
00:06:44 – send battle post content of the file and
00:06:49 – user ID to this image upload PHP script


Video Url:
http://youtu.be/sLzRXlfkc-g

Comments

comments