![]() |
php gurus question inside
I have an upload script
Code:
<?php i want it to remove the spaces in the file name when uploaded quick fix?????? also anytime i upload a file over like 1 meg i get There was an error uploading the file, please try again! i know what the issue is ... but i increase the size but i think im doing it right Code:
<html> what value would I put for like max 200megs |
you need to change the setting via php.ini or .htaccess to increase the limit over 1 meg...
|
Quote:
default server is liek 1 meg or something? |
create a phpinfo.php file and put <?php phpinfo(); ?> in it, it will tell you bunch of stuff about php, including your current upload file size limit...
|
damn woj you a gangsta
sho nuff max upload 2 megs now time to break my server and edit that lol |
and on a sidenote, be careful with a script like that, what you have there is not very secure, some loser can upload some script instead of a pic, letting him do whatever he wants on your server
|
Quote:
Code:
$filename=preg_replace("/\s+/g","",$filename); |
Quote:
|
Quote:
i get an error anywhere in partical i'd put that? |
as for removing spaces... you could always do urlencode($filename)
|
hmm
i changed it in php.ini but still says 2M in the phpinfo.php file do i gotta restart server |
upload_max_filesize 100M 100M
:-D fixed restarted apache instead of whole server woo |
hrmm it didnt seem to fix it woj
|
you could also do a string replace, I like them much better
$value = str_replace(" ", "", $value); Pretty simple stuff. As far as the php.ini changes, you do have to restart apache. There is also a browser limitation that you'll run into, as well as timeout issues, with files that large. |
Quote:
|
Also, for your target path, make sure its a full path. Will make life easier.
Ex. /home/yoursite/public_html/uploads |
Quote:
Now I'm not sure, but removing the spaces might actually cause it to fail. It may need to retain those spaces to know where the file is. Code:
<?php |
Quote:
hmm did that and it renamed the file to s3v%20c.jpgs3v%20c.jpg lol ah well ill look at this with a fresh head tommrow |
preg_replace is a good option but you can consider renaming every file to a unique string too.
This line: Code:
$tempfilename = str_replace(" ","", $_FILES['uploadedfile']['tmp_name']); Code:
$tempfilename = preg_replace('/[^a-z0-9\ ]+/i','',$_FILES['uploadedfile']['tmp_name']); Code:
$tempfilename = uniqid('upload-'); Looks like you're using move_uploaded_file incorrectly. You want the first value to be the actual file that was uploaded, and the second value to be the new destination and name for it. So, should be: Code:
$target_path = $target_path . $tempfilename; |
Full code would then look something closer to this (Untested):
Code:
<?php |
All times are GMT -7. The time now is 11:51 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123