I have a form with text inputs and file inputs; the text fields are being validated. Is there a way to have the form remember which files the user has already selected if they hit submit but need to go back because one of the text fields didn't validate?
A few years ago I benchmarked the two and CURL was faster. With CURL you create one CURL instance which can be used for every request, and it maps directly to the very fast libcurl library. Using file_get_contents you have the overhead of protocol wrappers and the initialization code getting executed for every single request.
I will dig out my benchmark script and run on PHP 5.3 but I suspect that CURL will still be faster.
In your url try:
(append whatever the rest of the URL for your API should be)
Here's what worked best for me when trying to script this (in case anyone else comes across this like I did):
$ pecl -d php_suffix=5.6 install <package> $ pecl uninstall -r <package> $ pecl -d php_suffix=7.0 install <package> $ pecl uninstall -r <package> $ pecl -d php_suffix=7.1 install <package> $ pecl uninstall -r <package>
-d php_suffix=<version> piece allows you to set config values at run time vs pre-setting them with
pecl config-set. The
uninstall -r bit does not actually uninstall it (from the docs):
vagrant@homestead:~$ pecl help uninstall pecl uninstall [options] [channel/]<package> ... Uninstalls one or more PEAR packages. More than one package may be specified at once. Prefix with channel name to uninstall from a channel not in your default channel (pecl.php.net) Options: ... -r, --register-only do not remove files, only register the packages as not installed ...
The uninstall line is necessary otherwise installing it will remove any previously installed version, even if it was for a different PHP version (ex: Installing an extension for PHP 7.0 would remove the 5.6 version if the package was still registered as installed).
Never used any of those, but they look interesting..
Take a look at Gearman as well.. more overhead in systems like these but you get other cool stuff :) Guess it depends on your needs ..
You can't "pre-fill" the contents of a file upload field for security reasons. Also, that would mean the file would get re-uploaded every time the form is submitted, which would not be good.
Instead, do this:
filecontaining the name of the just uploaded file.
file_uploadfield, process the upload and store the new value in
This mechanism can allow any user to claim other user's files as their own, by including a
filename that they guessed exists on your server. You will want to ensure that uploaded files are clearly associated with a specific user to avoid this issue.