473,406 Members | 2,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to upload a file using HTTP (without using FTP) ?

Hai everybody,
Im trying to upload an image using a form by using POST method and another PHP file to receive and upload the file. I used the following lines of code and it shows some error and probably wrong output too.

Expand|Select|Wrap|Line Numbers
  1. //index.php
  2. <html>
  3. <body>
  4.  
  5. <script language="javascript">
  6.   function preview()
  7.   {
  8.   document.STUDENT_PHOTO.src=document.myform.myimage.value;
  9.   }
  10.   </script>
  11.  
  12. <form name="myform" method="POST" enctype="multipart/form-data" action="disp.php">
  13. <img src="" alt="Click browse and locate the image." name="STUDENT_PHOTO" ID="STUDENT_PHOTO" height="170" width="170"/><BR />
  14. <input type="file" name="myimage" onchange="preview()" />
  15. <input type="submit">
  16. </form>
  17. </body>
  18. </html>
  19.  
  20.  
  21. //disp.php
  22. <?PHP
  23.  
  24. if(ISSET($_POST['myimage'])) 
  25. $student_photo=$name.$_FILES['myimage']['name'];
  26. //copy($_FILES['myimage']['tmp_name'],".\\images\\".$student_photo);
  27. echo $student_photo;
  28. }
  29. else
  30. {
  31. echo "No image found";
  32. }
  33.  
  34. ?>
It prints "No image found". It shows the same even if I use $_REQUEST['myimage'].

It prints "myimage" as undefined index and "name" as undefined variable if I use $_GET['myimage'].

(I have changed the form method type as GET, POST in index.php for the above test cases and got the above output)

Anybody pls help me.
Advanced Thanks...
Attached Files
File Type: zip code.zip (672 Bytes, 52 views)
Feb 25 '10 #1
2 2361
johny10151981
1,059 1GB
You will get thousands of solutions if you look at google

link. This was the first link that i got in search
Feb 25 '10 #2
Atli
5,058 Expert 4TB
Hey.

You use the $_FILES array to read files, not the $_POST array.

Look at the difference between how you read the image file in line #24 vs line #26. - You got it right in line #26.
Feb 25 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Thomas Brooks | last post by:
Hi there.... I have an ASP routine that I'm writing which updates an Access database with a user name, the file name, etc. all done through parameter processing and SQL functions. I do not...
4
by: Joe | last post by:
Hello, I have IIS 6.0 running on w2k3 Enterprise. I have three upload forms 1 to have restricted uploads .asp 2 to upload plain .asp any extension 3 a FP form upload non .asp
18
by: Jen | last post by:
I'm using Microsoft's own VB.NET FTP Example: http://support.microsoft.com/default.aspx?scid=kb;en-us;832679 I can get the program to create directories, change directories, etc., but I can't...
9
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
6
by: Vic Spainhower | last post by:
Hello, I am trying to do a FTP file upload which works fine on my localhost but on my ISP server it fails. I can't seem to find where I can go to find the specific cause of the failure. In both...
7
by: pbd22 | last post by:
hi. i am having probs understanding how to grab a file being uploaded from a remote client. i am using hidden input fields for upload such as: <input id="my_file_element" type="file"...
0
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
9
by: Steve Poe | last post by:
I work for an animal hospital trying to use PHP to store an animal's dental x-rays to a file server. I can browse for the xray on the local desktop computer then click "Upload Image". This...
10
by: Devang | last post by:
Hello, I am using php script to upload file. some times if file size is too big(1GB) it takes too much time to upload. Can someone suggest me the way to increase upload speed. thanks
6
by: Laphan | last post by:
Hi All I can't get round this because it's a local government thing, but I've done a CMS for a school (in ASP classic) that allows them to upload gifs, jpgs, pdfs and docs to their site for the...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.