Reputation: 791
I'm facing a very peculiar issue when attempting to grab the UUID from an image upload using upload care's PHP Library. The images are getting successfully uploaded back into my Uploadcare storage with their correlating UUID's, however in my php script when i attempt to grab the UUID from the file input, the request object is coming back an empty string.
Here are the imported Uploadcare script tags and input tag, respectively: *as instructed in the PHP Library Repo
<script>UPLOADCARE_PUBLIC_KEY = "2a92ab6d0aaae8efe942";</script>
<script src="https://ucarecdn.com/widget/2.9.0/uploadcare/uploadcare.full.min.js" charset="UTF-8"></script>
<input type="hidden" role="uploadcare-uploader" name="file_id" data-upload-url-base="">
Now I have noticed in the inspector console, during the uploading of the image, AND ONLY DURING THIS OCCURRENCE, I get the following
Failed to load resource. Could not connect to the server http://localhost:0/
error:
I've restarted my Server (using MAMP btw) numerous times. All my code seems to be correct as I noted earlier, the images are successfully being uploaded back into my Uploadcare storage...
ANY SUGGESTIONS?
UPDATE
Here is my code as constructed at the moment. I am using the Slim Framework in accordance with Twig as my templating engine:
use Uploadcare\Api;
$app->container->singleton('uploadcare', function() {
return new Api('2a92ab6d0aaae8efe942', 'SECRET KEY');
});
In my view I have the following twig syntax which produces the needed Uploadcare scripts and input tag:
<head>
{{ app.uploadCare.widget.getScriptTag | raw }}
<script>
UPLOADCARE_LIVE = false;
UPLOADCARE_DO_NOT_STORE = true;
UPLOADCARE_TABS = 'file';
UPLOADCARE_IMAGES_ONLY = true;
UPLOADCARE_CROP = 'free';
</script>
</head>
<body>
<form enctype='multipart/form-data' method="post">
{{ app.uploadCare.widget.getInputTag('file_id') | raw }}
</form>
</body>
now all I'm doing is a var_dump
on my request
object when the form is submitted, which shows the file_id
parameter coming back with an empty string rather than the UUID/new url of the uploaded image:
$request = $app->request;
var_dump($request->post('file_id'));
which echoes:
string(0) ""
UPDATE 2
below is a shot of the network activity during the selection of a file via uploadcare's api file input. As you can see, one of the GET request fail and I'm guessing that is the request that is causing the malfunction:
Upvotes: 2
Views: 436
Reputation: 6937
Just remove data-upload-url-base=""
, it instructs the widget to use "empty" upload servers instead of upload.uploadcare.com
Upvotes: 0