简体   繁体   中英

call php script from file on hard drive in html form

I've got a form that calls a php script that I borrowed from a website. The form works when I call the php from the website.

I'm running my site just off of my localhost and I wanted to tweak the php a bit so I copied the code and I tried to call it from a file on my hard drive but it doesn't work anymore. Can you not call a file in the action part of an html form?

This code works

<form action="http://malsup.com/jquery/form/file-echo2.php" method="post" enctype="multipart/form-data">
    <input type="file" name="myfile"/>
    <input type="submit" value="Submit File"/>
</form>

This code does not work

<form action="file:///Users/joedanger/Python/static/upload.php" method="post" enctype="multipart/form-data">
    <input type="file" name="myfile"/>
    <input type="submit" value="Submit File"/>
</form>

I guess it would first help to know which operating system you are currently developing on. There are a couple options if you don't have a web environment to test on. One option is to setup apache on your computer and then run the files within the web folder (speaking in terms of Mac OSX) http://php.about.com/od/phpbasics/ss/installMac.htm

If you are using a windows operating system, PHP has a quick step by step walkthrough on how to set this up. http://www.php.net/manual/en/install.windows.php

Hope this helps, Good luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM