/    Sign up×
Community /Pin to ProfileBookmark

Hi,

I am trying to upload a directory of small image files. I have the directory name and an array of filenames to upload. I can’t seem to use moveupload as it doesn’t work . Here is an example. I didn’t want to upload 1 file at a time so I am doing abatch upload if possible.

$file=”c:/www/php/imagetest/one33.jpg”;
$target_path= “c:/www/php/images2”;

if(move_uploaded_file($file, $target_path)) {
echo “<strong>Please enter details for your photo you uploaded as
“. ( $filename).
” to be entered into the system</strong>”;
} else{…..
//nothing gets uploaded and the error is moveuploaded returned false.

q)Is it possible to uplad multiple images from a directory using php eg just give directory name and all file are upladed like 50 of them?

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@so_is_thisNov 20.2006 — [B]move_uploaded_file()[/B] isn't going to work unless that particular file was actually and currently uploaded via the browser's [B]INPUT TYPE=FILE[/B] control element -- i.e., the file name specified must be the temp file name created by PHP during PHP's HTTP POST upload processing. Also, there are no PHP functions which perform operations on all files in a given folder. Any such functions work on a single file at a time and must be executed in a loop in order to process all files in a given folder.
Copy linkTweet thisAlerts:
@CrazyGazNov 20.2006 — q)Is it possible to uplad multiple images from a directory using php eg just give directory name and all file are upladed like 50 of them?[/quote]

The only way I can think to do this is to create a zip file of the images, then unzip them on the server.
Copy linkTweet thisAlerts:
@jagguyauthorNov 20.2006 — q)Without spending hours finding out, can you upload a zip file, read the filenames into an array or something and store them on your server.

q) to install zip on php with winxp, I uncomment the php.ini and goto the extension=php_zip.dll and restart apache.

The I run the this to test it and it fails with error

Fatal error: Cannot instantiate non-existent class: ziparchive in C:wwwphpzip1.html on line 3

Does this mean it is not installed? I did the same process with GD and it worked for that.

<?php

$zip = new ZipArchive();

$filename = "./test112.zip";

if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {

exit("cannot open <$filename>n");

}

$zip->addFromString("testfilephp.txt" . time(), "#1 This is a test string added as testfilephp.txt.n");

$zip->addFromString("testfilephp2.txt" . time(), "#2 This is a test string added as testfilephp2.txt.n");

$zip->addFile($thisdir . "/too.php","/testfromfile.php");

echo "numfiles: " . $zip->numFiles . "n";

echo "status:" . $zip->status . "n";

$zip->close();

?>
×

Success!

Help @jagguy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...