LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 08-01-2016, 03:13 PM   #1
pizzipie
Member
 
Registered: Jun 2005
Location: Hayden, ID
Distribution: Ubuntu 20.04
Posts: 441

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


HI,

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.

Code:
<!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:
-->

<html>
<body>

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

</body>
</html>
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,

R
Attached Thumbnails
Click image for larger version

Name:	Selection_067.png
Views:	21
Size:	35.5 KB
ID:	22631  
 
Old 08-01-2016, 07:57 PM   #2
24x7servermanagement
Member
 
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, 08:13 PM   #3
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
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 08:15 PM.
 
Old 08-01-2016, 09:51 PM   #4
pizzipie
Member
 
Registered: Jun 2005
Location: Hayden, ID
Distribution: Ubuntu 20.04
Posts: 441

Original Poster
Rep: Reputation: 12
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
file.
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.

R
 
  


Reply



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 10:21 PM
upload image to db "php + mysql" ALInux Programming 1 12-15-2005 11:27 AM
can not upload image to site via php script vinsky2002 Linux - Software 0 03-15-2005 12:27 AM
Upload Script....but not php vous Programming 1 02-04-2004 02:13 PM
What's a good php upload script for this? kleptophobiac Programming 2 01-31-2004 07:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:19 PM.

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