473,671 Members | 2,558 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem in php script to upload a file

20 New Member
The upload html page i'm using

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head> <title> </title></head>
  3. <body> 
  4. <form enctype="multipart/form-data" name="upload" action="upload.php" method="post">
  5. <input  name="file4upload"  type="file"> </input> <br>
  6. <input name="submit" type="button" value="Upload File" > 
  7. </form>
  8. </body>
  9. </html>
  10.  
  11.  

php file code is given below (upload.php)

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $target_path="upload/";
  3. $target_path=$target_path.basename($_FILES['file4upload']['name']);
  4. if(move_uploaded_file($_FILES['file4upload']['tmp_name'],$target_path))
  5. {
  6. echo " File ".basename($_FILES['file4upload']['name'])."has been uploaded";
  7. }
  8.  
  9.  
  10. else
  11. {
  12. echo "Unsuccessful";
  13. }
  14.  ?> 
  15.  
i couldn't succeed in this simple upload scipt.Breaking my head for past two days.Kindly help me
It gives me following error

Notice: Undefined index: file4upload in C:\Documents and Settings\All Users\Documents \PHP practice\upload .php on line 3

Notice: Undefined index: file4upload in C:\Documents and Settings\All Users\Documents \PHP practice\upload .php on line 4
Unsuccessful


PHP version used 5.1
IIS version : 5.1
OS : Win Xp

Hope u'll all help me...Thanx
Jul 12 '12 #1
2 2112
lyodmichael
75 New Member
what kind of file do you need to upload?
Jul 15 '12 #2
shanboy
20 New Member
Solution: i had not close the <input> tag. Nowit is works.
Jul 16 '12 #3

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

Similar topics

1
2871
by: Muppy | last post by:
I've created a page with a form to upload files: <h1>Upload di un file</h1> <form enctype="multipart/form-data" method="post" action="do_upload1.php"> <p><strong>File da trasferire:</strong><br> <input type="hidden" name="MAX_FILE_SIZE" value="1000000"> <input type="file" name="img1" size="30"> </p> <p> <input type="submit" name="submit" value="Upload File">
2
1432
by: Brian | last post by:
Hi, I've been trying to find a way to upload file to another site that is not using IIS. The site that I want to upload file to has a simple php script to receive file uploaded through standard http post with a file upload. However, how do I upload file to the site using asp.net? thanks Brian
3
2423
by: Brian | last post by:
Hi, I've been trying to find a way to upload file to another site that is not using IIS. The site that I want to upload file to has a simple php script to receive file uploaded through standard http post with a file upload. However, how do I upload file to the site using asp.net? thanks Brian
0
918
by: zamuel | last post by:
I have an upload problem. When I push the button the file should be saved to files folder. The if sentence doesn't work altough I browse file to "MyFile1" before pushing th button. Any ideas? private void OKButton_Click(object sender, System.EventArgs e) { string strFileName1="NULL"; if ((MyFile1.PostedFile.FileName != "") && (MyFile1.PostedFile!=null) && (MyFile1.PostedFile.ContentLength>0)) { strFileName1 =...
2
1705
by: suresh_nsnguys | last post by:
Hi, I am working in digital signage application where user can upload image,flash and movie files .and later thay can view the uploaded files in digital LCD screen. I am facing 1 issue.i able to store the uploaded files in 1 single directory in server.but i am afraid that how many files will be stored in 1 single directory.Bcz in the future,my upload files can reach say1 lakth.i am not sure whether a single directory can handle...
4
9171
by: google.com | last post by:
Hi there! I've been digging around looking for a sample on how to upload a file without user action. I found the following article covering the area: http://www.motobit.com/tips/detpg_uploadvbaie/ It describes the vba code required to handle a very simple upload form:
3
4000
by: kujtim | last post by:
i got html code file name html <html> <head> <title></title> </head> <body>
1
8283
by: printline | last post by:
Hello all I have a php script that uploads a file from a form into a directory. The directory is automatically created through the script. But the upload file is not put in to the directory, but outside.... Can anyone tell what i am doing wrong....?? And perhaps tell me what to do to put the file into the created directory...? Here is my code:
5
1884
by: petershaman | last post by:
Hi I have a gorgeous flash image gallery, it would work perfectly fine but there's a small problem I can't upload anything thru it's upload script, since I'm getting an error 403. It's so because server sets by default CHMOD 600, whilst gallery needs to be set 644 to operate correctly. In this upload php script there is a command which theoretically should change permissions for uploaded files, but it's not doing the job, there's obviously...
2
9424
by: lka527 | last post by:
I am trying to make a site available for someone to *upload* certain type of text file (.txt) that can be parsed by written code. the upload file is available on the main site but I need this to result in different page on the right as someone clicks on SUBMIT with one's file attached. The uploaded file by clicking submit button should be PARSED on the right side of the page but when I click on the submit with the file now, it goes to the local...
0
8485
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8403
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8605
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8677
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7446
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5704
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2819
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2062
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.