Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Whitespace In File Upload
Old 03-05-2005, 03:29 PM Whitespace In File Upload
Logical Program's Avatar
Super Talker

Posts: 130
Location: Atlanta, Georgia
Trades: 0
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..
Logical Program is offline
Reply With Quote
View Public Profile Visit Logical Program's homepage!
 
 
Register now for full access!
Old 03-05-2005, 04:08 PM
Logical Program's Avatar
Super Talker

Posts: 130
Location: Atlanta, Georgia
Trades: 0
WOO! This worked!

PHP Code:

        $uploadDir 
'temp_models/';

        
$datearr = @getdate();

        
$id $datearr[wday].''.$datearr[mon].''.$datearr[mday].''.$datearr[seconds].''.$datearr[year];

        
$uploadFile1a $uploadDir $id $_FILES['previewpic']['name'];
        
        
$uploadFile1 str_replace(' ''_'$uploadFile1a);
        
        
$uploadFile2a $uploadDir $id $_FILES['secondarypic']['name'];
        
        
$uploadFile2 str_replace(' ''_'$uploadFile2a);

        
$uploadFile3a $uploadDir $id $_FILES['thirdpic']['name'];
        
        
$uploadFile3 str_replace(' ''_'$uploadFile3a);

        
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.
Logical Program is offline
Reply With Quote
View Public Profile Visit Logical Program's homepage!
 
Reply     « Reply to Whitespace In File Upload
 

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23878 seconds with 12 queries