Jump to content

Storing a file in a php array?


unknown101

Recommended Posts

 

Hi Guys,

 

Im reasonably new to php but am working on quite a difficult project so please take this into account!  I have been searching the internet for examples of how to transmit data to a given server (for example a simple .php server).  At the moment im not interested in how the server side deals with it but just how the client side does.

 

The front end gives the user the abiltiy to upload a fie (say in this case an image .jpg).  Basically the file is selected into an upload field and then a submit button hit.  From here is where I need help :)  How will the image will be stored so it can be transmitted?  I know in java you can use byte arrays, but I dont seem to be able to find anything useful on the web to do this in php?

 

Can anyone point me in the right direction for storing a file in a .php script then sending...?

 

Thanks in advance.

Link to comment
Share on other sites

I doing something similar as well... so welcome to the club :P

 

for the server part you need to play with sockets. a general idea is very well documented in the below site http://www.devshed.com/c/a/PHP/Socket-Programming-With-PHP/

 

for the client part you can do with sockets as well or curl www.php.net/curl, but you can use the function ftp www.php.net/ftp for client/server. I read somewhere that ftp function is very slow procedure, curl and sockets need half time to complete the transfer against ftp functions of php.

 

more specific for the client check www.php.net/sockets and go to the Example 2285. it shows exactly how to implement a client via sockets.

 

Link to comment
Share on other sites

Hi there,

 

Ive be reading through the tutorial provided above (http://www.phpfreaks.com/tutorials/85/0.php) but have found this assumes the file is going to be stored in a directory.

 

For the moment I just want to get the file to upload and at the server side store the file in memory (so for example in an array)...

 

So would this be a case of taking the file the user has selected, passing it to a variable, then transmitting this in an array? (If i was to do this in java, I could use a byte array but im not entirely sure how to do this in php).

 

Any help is appreciated.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.