I have a website which i created, and part of it is a PHP form which allows users to upload images. This has always worked, but stopped working today, with no visible error. Has anything changed on the hosting side? It isn’t a filesize issue since the image is 300kb in size.
Thank you
Herbert
November 23, 2023, 1:30am
2
I’ve checked your uploader, and it seems there aren’t any issues. Could you be more specific about the question? And try turning on PHP debugger from Cpanle.
Try uploading a new recipe with an image using the above link.
It should add the picture with the recipe.
Herbert
November 23, 2023, 1:53am
5
Could you please share your Upload logic?
if(!empty($_FILES["imageupload"]["tmp_name"]))
{
$targetDir = "../images/";
$fileName = $_POST['ID'] . ".jpg";
$targetFilePath = $targetDir . $fileName;
$fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION);
move_uploaded_file($_FILES["imageupload"]["tmp_name"], $targetFilePath);
}
else
$fileName = NULL;
Keep in mind the code works properly on localhost
Herbert
November 23, 2023, 1:58am
7
It generally seems okay, but try removing two dots from tragetdir
if(!empty($_FILES["imageupload"]["tmp_name"]))
{
$targetDir = "/images/";
$fileName = $_POST['ID'] . ".jpg";
$targetFilePath = $targetDir . $fileName;
$fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION);
move_uploaded_file($_FILES["imageupload"]["tmp_name"], $targetFilePath);
}
else
$fileName = NULL;```
you can sign up for an account to test if you’d like
No, that didn’t work. The script that processes the upload is in a subfolder /api/
Herbert
November 23, 2023, 2:04am
10
Check your images folder; I uploaded a smiley png.
Nope, the image was not saved, nor was the image filename written to my database.
Herbert
November 23, 2023, 2:08am
12
Okay, i tested this with my website and it worked for me, try this
$targetDir = __DIR__ . "/../images/";
1 Like
That didnt work.
!empty($_FILES[“imageupload”][“tmp_name”]) is resolveing to true, so the code to rename the file never runs.
Herbert
November 23, 2023, 2:19am
14
Provide me the full code, without it i can’t know for sure what’s the issue.
I’ve done some debugging, and this is the error on the file uploaded.
UPLOAD_ERR_NO_TMP_DIR, value 6, means that no temporary directory is specified in the
php.ini.
Herbert
November 23, 2023, 2:40am
16
Below code works for me,
($_FILES["files"]["tmp_name"])
And I can’t be of any help unless you provide your full uploading code.
SoftHub
November 23, 2023, 2:45am
17
samf2114:
I’ve done some debugging, and this is the error on the file uploaded.
UPLOAD_ERR_NO_TMP_DIR, value 6, means that no temporary directory is specified in the
php.ini.
this could be related to the tmp folder issues all wordpress hostings on IF are currently having.
Can you share the thread on this please? Must be the same thing.
Something seems to be wrong with the php.ini config
Herbert
November 23, 2023, 2:58am
20
Hey, it’s not an error from your end; it’s a server issue. I checked with my website, and my images are not uploading either.
1 Like