![]() |
PHP Help!
Ok, I'm in the process of creating a php script to upload multiple files, give them a unique id and store them on the server for download via WAP, hit a wall though in that for some reason I can't upload files over 10Kb in size, MAX_UPLOAD in php.ini is set to the default 8M (Scripts on i-web but working on it in uni) Apache timeout is 30s and uploads set to 2M, sorry for the sloppy code (some doesn't need to be there any more) but can anyone spot the problem?
PHP Code:
Quote:
|
Re: PHP Help!
what's DOCUMENT_ROOT set to in config.php? (in fact, can you paste that file too?)
|
Re: PHP Help!
DOCUMENT_ROOT is a php reserved variable to automatically fine out the root, but here's config.php anyway:
PHP Code:
|
Re: PHP Help!
Without wanting to state the obvious, it looks like it's either uploading the file into a different path than the one filesize is looking for or it's not uploading it at all, sorry, I can't be anymore help than that, I'm sure Richard M or someone can put you right.
|
Re: PHP Help!
thing is it works fine for file 9.99Kb or less and it is putting them in the right place, why would it change for a file larger than that?
|
Re: PHP Help!
Quote:
|
Re: PHP Help!
Nope, I'm at uni now using their internal system straight to the webserver, does the same thing on NTL though.
|
Re: PHP Help!
Has it got any other files, (like class.php) I can test it here if you like.
|
Re: PHP Help!
Not really, all it has is config.php, the upload page index.php and the processor uploadfile.php plus a simple table in a MySQL database.
class.php PHP Code:
PHP Code:
|
Re: PHP Help!
what about require_once("class.php"); in config.php ?
|
Re: PHP Help!
couple of things, fileid won't be random enough, i use :
$server_filename = md5(microtime() . $_FILES['upfile']['name']) . $extension; for random filenames 2nd, is the directory /var/www/htdocs/prin/u1r08/wap/uploaded/ actually there and read/writeable by the user the webserver runs as 3rd, try using move_uploaded_file($_FILES['upfile']['tmp_name'][$idx], $dst) instead of the copy |
Re: PHP Help!
Quote:
Quote:
Quote:
Quote:
|
Re: PHP Help!
Why are you using usleep()?
|
Re: PHP Help!
Oops that slipped in from an earlier effort makes no difference on this loop though.
|
Re: PHP Help!
If you are able to wait until after 6 I'll post some of my own code which works.
|
Re: PHP Help!
yeah sure, although I will have to credit you so PM me your details if you want. In the mean time if I crack it I'll post back here!
|
Re: PHP Help!
As promised, this is the code I use for an image upload script - it's highly cut down because I do a helluva lot more with mine such as working out pixel counts etc (demo here: http://www.richardm.co.uk/gallery/?c...on=Screenshots)
Also, I think this code is an older version than what I'm using now but it should work. HTML, important bits are marked in bold: Quote:
PHP Code:
|
Re: PHP Help!
Ah thanks for the effort, seen lot of these types of script whilst searching the web, not quite what I want but could be adapted, I really want to know why mine doesn't work though and if anything can be done to fix it. I shall fiddle around with your version though and add my ID loop and see how it goes.
|
Re: PHP Help!
I have had a quick look and it looks like the file is not being written fast enough so by the time it gets to line 29 ($fsize = filesize($dst)) the file can not be found. I can only assume that the processing continues immediately after the line copy($src, $dst) and the OS hasn't written the file yet. That would explain why small files work and large files don't. I've never used the usleep() function before but I can guess that it will act as a pause so either increase this and see what happens.
If it is what I suspect then there are several ways around this: 1. put a loop in to check for the existance of the file before continuing, use the file_exists() function. 2. use the system() function to do the copying. It should then wait for OS to finish processing before it continues processing the script. 3. if all you are after is the file size then you should be able to do something like $fsize = $_FILES['upfile']['size'][$idx] to get the size of the current file. |
Re: PHP Help!
You're all brilliant! $fsize = $_FILES['upfile']['size'][$idx] seems to have fixed it, don't know why I didn't spot it! So thanks to iron25, Richard M and others, greenies for you all!:):)
I was thinking along the same lines as you iron25 so we must've been right, strange that it happens at exactly 10k, on PHP4 and 5 and on different server setups. |
| All times are GMT. The time now is 11:03. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
All Posts and Content are © Cable Forum