0

I'm trying on a project, that i need to create a progress bar while uploading some file with php.

I find this example;

http://www.johnboy.com/php-upload-progress-bar/

But the progress bar is not working in my PHP 5.4 local server, or any my internet server that PHP5.4 too.

I have knowladge about the bar building like width: x% but i cant get the progress variable.

Is there any code that i can check the file's uploaded size, while i'm uploading it?

theCurrentUploadedSize($_FILES["thefile"]);

or like

theCurrentSize("path/to/thefile/whileuploading");

Any help or link might help me, i dont have any knowladge about file management with php.

-----------Solved-----------------

The problem was about the APC add-on for the PHP. If you have such problem, look for how to install Alternative PHP Cache Add-on.

Burak Tokak
  • 1,810
  • 1
  • 20
  • 27
  • 1
    you can achive this with jQuery: see [File upload progress bar with jquery](http://stackoverflow.com/questions/15410265/file-upload-progress-bar-with-jquery) – ponciste Apr 04 '14 at 14:55
  • Yes i tryed that one, but you need to include a plugin for that, i want something more efficient, may a php expert will help me about it. – Burak Tokak Apr 04 '14 at 14:57
  • 1
    Did you read the requirements regarding APC? *"Make sure you have APC installed on your server. It won't work without it. It's easy to install, so if you don't have root acces to your server, ask your hosting provider to take care of it for you."* --- That could be the reason. – Funk Forty Niner Apr 04 '14 at 14:57
  • 2
    why do you think PHP would be more efficient then jQuery even if this need a 14KB plugin to be included? ... – ponciste Apr 04 '14 at 15:00
  • @Fred -ii- i'm trying it right now. Thankyou for the notice. – Burak Tokak Apr 04 '14 at 15:00
  • 1
    You're welcome. FYI: It didn't work for me neither, so I'm in the same boat as you are. The file uploaded correctly, just no progress bar. – Funk Forty Niner Apr 04 '14 at 15:02
  • @ponciste i dont know, php is older then jQuery, it might be a reason. – Burak Tokak Apr 04 '14 at 15:04
  • 1
    @Fred -ii- yes its writing NaN in the progress bar. I'll give update after i install that APC thing. – Burak Tokak Apr 04 '14 at 15:06
  • 1
    That code uses the function apc_fetch(); so if you dont have installed APC it's not going to show the progress var xD – Hackerman Apr 04 '14 at 15:08

1 Answers1

1

have you had a look at the upload progress functionallit built into PHP since 5.4?

There is a good description at http://oliversmith.io/technology/2011/12/04/php-5-4-file-upload-progress-and.html5-progress-bars/

heiglandreas
  • 3,803
  • 1
  • 17
  • 23