Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

PHP Page Just Shows Code

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

PHP Page Just Shows Code

Postby TedN » 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.

HTML CODE:
Code: Select all
<html>
<body>

<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" />
 </form>

</body>
</htm>


PHP CODE:
Code: Select all
<?php
 $target = "upload/";
 $target = $target . basename( $_FILES['uploaded']['name']) ;
 $ok=1;
 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.
TedN
New php-forum User
New php-forum User
 
Posts: 11
Joined: Sat Feb 23, 2013 8:00 pm

Re: PHP Page Just Shows Code

Postby aravindoptimus » 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.
User avatar
aravindoptimus
New php-forum User
New php-forum User
 
Posts: 11
Joined: Thu Mar 07, 2013 2:00 am

Re: PHP Page Just Shows Code

Postby seandisanti » 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.
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 775
Joined: Mon Oct 01, 2012 12:32 pm


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.