Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 08-01-2016, 04:13 PM   #1
Registered: Jun 2005
Location: Hayden, ID
Distribution: Ubuntu 20.04
Posts: 388

Rep: Reputation: 9
PHP - upload program won't run action "upload.php" script


I have not tried file uploading before and can't seem to get it to work the way I want it to. The end result I want is to select a group of photos and upload them to "upload.php" where they will be renamed and stored to another directory.

<!DOCTYPE html>

<!--PHP 5 File Upload

With PHP, it is easy to upload files to the server.

However, with ease comes danger, so always be careful when allowing file uploads!
Configure The "php.ini" File

First, ensure that PHP is configured to allow file uploads.

In your "php.ini" file, search for the file_uploads directive, and set it to On:
file_uploads = On  ... This I have done.

Create The HTML Form

Next, create an HTML form that allow users to choose the image file they want to upload:


<form action="/home/rick/Desktop/PHP.HTML/upload.php" method="post" enctype="multipart/form-data">
    Select image(s) to upload:
    <input type="file" name="myFiles[]" multiple="">
    <input type="submit">

When I run this "fileUpload.html" script A window opens offering me to open the php script with some application or to save the file. I want my php script to run.

I apparently don't understand something basic here.

Thanks for any help to fix this,

Attached Thumbnails
Click image for larger version

Name:	Selection_067.png
Views:	17
Size:	35.5 KB
ID:	22631  
Old 08-01-2016, 08:57 PM   #2
Registered: Jul 2016
Location: India
Distribution: CentOS, Redhat, Ubuntu and Debian
Posts: 57

Rep: Reputation: Disabled
You will need to check your .htaccess and make sure that correct Apache handler is added.

If there is any handler added then remove it first and then try again. Depends on your PHP version the handler needs to be added/modified.
Old 08-01-2016, 09:13 PM   #3
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_12{.0|.1}
Posts: 5,791
Blog Entries: 23

Rep: Reputation: 3808Reputation: 3808Reputation: 3808Reputation: 3808Reputation: 3808Reputation: 3808Reputation: 3808Reputation: 3808Reputation: 3808Reputation: 3808Reputation: 3808
It doesn't work like that. And adding an apache handler will not work if you are not using apache to access the file!

You are trying to open the file (/home/rick/Desktop/PHP.HTML) on your local machine. There is no web server or php handler in play so it will only ever see it as "a file" and never execute the PHP "as code" in the file.

You must have a web server running and configured to hand off the mime-type (html) to the php interpreter. And you must access the file via the web server, not the filesystem.

Once that happens you will still need more PHP code to receive the submitted form, process and move the submitted files into some permanent location. But that also asks the question, "Why upload files from your local system to your local system?". That is probably not what you actually have in mind.

Apparently you do indeed not understand how PHP and web servers work together.

It would be very helpful to others if you could provide bit more information on your system and what you are trying to accomplish.

Last edited by astrogeek; 08-01-2016 at 09:15 PM.
Old 08-01-2016, 10:51 PM   #4
Registered: Jun 2005
Location: Hayden, ID
Distribution: Ubuntu 20.04
Posts: 388

Original Poster
Rep: Reputation: 9
Maybe I don't need to use "upload" at all?

Here is what I want to do.

1. Let user browse file system to select a directory or group of files.
2. Send the directory or files to my script "transferImages.php".
3. This script reads the EXIF information for each file and calculates a 'timestamp' for the
4. The 'timestamp' is then pre-pended to the file name and the file transferred to a the final folder.

Any ideas or solutions welcome.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] problems with PHP, showing code trying to "run" a php file? michaelinux Slackware 1 12-29-2010 11:21 PM
upload image to db "php + mysql" ALInux Programming 1 12-15-2005 12:27 PM
can not upload image to site via php script vinsky2002 Linux - Software 0 03-15-2005 01:27 AM
Upload Script....but not php vous Programming 1 02-04-2004 03:13 PM
What's a good php upload script for this? kleptophobiac Programming 2 01-31-2004 08:06 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:32 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration