PHP Page Just Shows Code

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 11
Joined: Sat Feb 23, 2013 8:00 pm

Wed Feb 27, 2013 9:39 am

When I call upload.php from upload.htm my browser just shows the code of upload.php, i.e. it doesn't upload a chosen file.


Code: Select all


<form enctype="multipart/form-data" action="upload.php" method="POST">
 Please choose a file: <input name="uploaded" type="file" /><br />
 <input type="submit" value="Upload" />


Code: Select all

 $target = "upload/"; 
 $target = $target . basename( $_FILES['uploaded']['name']) ; 
 if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) 
 echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
 else {
 echo "Sorry, there was a problem uploading your file.";
Both the html and php files are located in my www folder. The WAMPSERVER is online.

Appreciate any help.

User avatar
New php-forum User
New php-forum User
Posts: 11
Joined: Thu Mar 07, 2013 2:00 am

Thu Mar 07, 2013 4:04 am

I have checked with you code and its running in my WAMP. I think your Apache or PHP is not running properly.

php-forum Fan User
php-forum Fan User
Posts: 974
Joined: Mon Oct 01, 2012 12:32 pm

Thu Mar 07, 2013 12:09 pm

what do you see when you navigate to http://localhost in your browser? also, what version of windows are you running? Depending on your setup, you may have IIS starting on its own and listening on port 80. Click on your wamp icon, then go to apache, then service, and see if it gives you the option to start or stop the service. if the service is running correctly, it will have 'stop service' enabled. otherwise check out the error log right off of the apache menu and it will tell you why it's not running. Most often (in my recent experience) it's because port 80 is already in use from IIS.

Post Reply