unknown101 Posted November 22, 2007 Share Posted November 22, 2007 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. Quote Link to comment Share on other sites More sharing options...
anatak Posted November 22, 2007 Share Posted November 22, 2007 go to the php tutorial section and look for writing an upload class in OOP here is the link http://www.phpfreaks.com/tutorials/85/0.php I hope that can help you Quote Link to comment Share on other sites More sharing options...
snk Posted November 22, 2007 Share Posted November 22, 2007 I doing something similar as well... so welcome to the club 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. Quote Link to comment Share on other sites More sharing options...
unknown101 Posted November 25, 2007 Author Share Posted November 25, 2007 Thanks for the help guys, im gona give the tutorial a run through! Quote Link to comment Share on other sites More sharing options...
unknown101 Posted November 26, 2007 Author Share Posted November 26, 2007 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.