LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-18-2023, 06:38 PM   #1
pizzipie
Member
 
Registered: Jun 2005
Location: Hayden, ID
Distribution: Ubuntu 20.04
Posts: 441

Rep: Reputation: 12
PHP/AJAX - Any way to Upload or transfer files from Ajax to folder


I have an object containing image files(jpg, png, etc) that I send via AJAX to a program that, hopefully, can upload all the files to a target folder. All I can find in any documentation is that you have to have a "multipart/form-data" form type="file" to submit one file at a time via submitting. I am trying to process 7000 files(re-naming, re-sizing etc) so this obviously will not work.

I tried to copy() the files but that doesn't work.

Thanks in advance for help in trying to make this work.

R

Code:
$.ajax({
  type: "POST",
  url: "upload3.php",
  data: { ajaxArr }
});
 // ==============================
 

//upload3.php

$imageArr=$_POST['ajaxArr'];

for($i=0; $i<count($imageArr); $i++) {
	echo $i.". ".$imageArr[$i]."<br>";
}
 
Old 07-18-2023, 06:43 PM   #2
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,226

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Quote:
I am trying to process 7000 files
You only need to upload one file. Have the web form take an archive.

If you're going to insist on a) having a web-based interface for this, and b) uploading individual files, then you obviously don't want browser-based UI. Just have a URL that takes uploads via cURL.

Last edited by dugan; 07-18-2023 at 06:48 PM.
 
Old 07-18-2023, 09:22 PM   #3
pizzipie
Member
 
Registered: Jun 2005
Location: Hayden, ID
Distribution: Ubuntu 20.04
Posts: 441

Original Poster
Rep: Reputation: 12
Thanks for the reply.

Quote:
Just have a URL that takes uploads via cURL.
What does this mean relative to what I'm doing?

I have dozens of CD's + external hard drives. I want to process each of them Directory by Directory not deal with 7000 at once.

At present I use a Select Box to choose multiple files and then send them as an array-like object via AJAX to program called upload3.php. In the Ajax call the url is upload3.php.

If I use cURL how do I send these files to, say, the "/home/rick/Desktop/A52_Photos/2023/July" directory.
Attached Files
File Type: pdf selectionBox.pdf (13.4 KB, 18 views)

Last edited by pizzipie; 07-18-2023 at 09:48 PM. Reason: add more detail
 
Old 07-18-2023, 11:29 PM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,866
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
I think Ajax is JavaScript, so it has nothing to do with PHP.
Try these:
https://www.php.net/manual/en/featur...ost-method.php
https://www.php.net/manual/en/features.file-upload.php
 
Old 07-19-2023, 08:55 AM   #5
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,662
Blog Entries: 4

Rep: Reputation: 3943Reputation: 3943Reputation: 3943Reputation: 3943Reputation: 3943Reputation: 3943Reputation: 3943Reputation: 3943Reputation: 3943Reputation: 3943Reputation: 3943
NevemTeve (and for the "peanut gallery"), "AJAX" effectively refers to a form of "remote procedure call" using the HTTP protocol asynchronously. The requests are initiated and completed using JavaScript "behind the scenes."

You cannot directly send "files" this way, AFAIK, but the OP could use JavaScript commands to initiate individual file-upload requests to the server, having first been supplied with the list of files by means of an AJAX-initiated reply.
 
  


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
PHP - upload program won't run action "upload.php" script pizzipie Linux - Software 3 08-01-2016 09:51 PM
I can not find/use F spot in any way. Nor can I find a way to upload pictures from m old biker Linux - Newbie 1 07-12-2015 08:36 PM
[SOLVED] create sub-folder from folder name and transfer files on the fly BoydRice Linux - General 5 03-07-2012 07:44 PM
Proftpd upload to a folder other than 'upload' fooboo Linux - Software 4 04-27-2006 07:51 PM
IglooFTP-PRO refuses to upload files in folder when I upload folder eBopBob Linux - Software 0 08-27-2004 05:52 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:34 AM.

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