Posts: 130
Location: Atlanta, Georgia
|
I've written a file upload script... The file input fields are previewpic, secondarypic, and thirdpic.
I'm using the $_FILES superglobal, and move_uploaded_file(); to do the upload.
For some reason, whenever a file containing a space is uploaded, the upload fails.
I really don't want to change the structure of the upload. Is there any way to string replace the spaces for underscores?
I tried str_replace(' ', '_', $_FILES[previewpic][name]); before the move_uploaded_file, but it didn't work.
Any ideas?
Here's The Code:
PHP Code:
$uploadDir = 'temp_models/';
$datearr = @getdate();
$id = $datearr[wday].''.$datearr[mon].''.$datearr[mday].''.$datearr[seconds].''.$datearr[year];
$uploadFile1 = $uploadDir . $id . $_FILES['previewpic']['name'];
$uploadFile2 = $uploadDir . $id . $_FILES['secondarypic']['name'];
$uploadFile3 = $uploadDir . $id . $_FILES['thirdpic']['name'];
move_uploaded_file($_FILES['previewpic']['tmp_name'], $uploadFile1);
move_uploaded_file($_FILES['secondarypic']['tmp_name'], $uploadFile2);
move_uploaded_file($_FILES['thirdpic']['tmp_name'], $uploadFile3);
__________________
Please login or register to view this content. Registration is FREE - For all of your website programming and design needs, make the logical choice. Logical Assistance For Real-World Clients.
Last edited by Logical Program; 03-05-2005 at 03:38 PM..
|